Блог*
#prog #rust Хозяйке на заметку Если вы когда-нибудь писали на Rust какую-нибудь рекурсивную структуру, то у вас там наверняка было поле вроде Option<Box<Self>> или Option<Rc<Self>>. Для обхода подобной структуры требуется получить ссылку из поля такого типа.…
Telegram
Мне не нравится реальность
У каждого программиста на расте наступает такой момент, когда он открывает что-то вроде и очевидное, но неожиданное.
Среди такого можно отметить например .collect::<Result<Vec<_>, _>> или упомянутые в статье ниже Option::as_deref{,_mut} (ну и Result::as_deref{…
Среди такого можно отметить например .collect::<Result<Vec<_>, _>> или упомянутые в статье ниже Option::as_deref{,_mut} (ну и Result::as_deref{…
#prog #c #cpp #article
Так как регулярно возникает странное мнение, что UB — это не страшно, вот статья с примером, как UB может привести к вызову никогда не вызываемой функции. Old but gold, как говорится.
https://kristerw.blogspot.com/2017/09/why-undefined-behavior-may-call-never.html
Так как регулярно возникает странное мнение, что UB — это не страшно, вот статья с примером, как UB может привести к вызову никогда не вызываемой функции. Old but gold, как говорится.
https://kristerw.blogspot.com/2017/09/why-undefined-behavior-may-call-never.html
Blogspot
Why undefined behavior may call a never-called function
My twitter feed has recently been filled with discussions about the following program #include <cstdlib> typedef int (*Function)(); s...
Forwarded from codingteam@cjr
Minoru
о! Кстати! В продолжение дискуссии про макру python!, встраивающую Python в Rust: это же фактически реализация принципа «язык под задачу». Просто выбираешь, что тебе удобнее написать на Rust, а что на Python…
о! Кстати! В продолжение дискуссии про макру python!, встраивающую Python в Rust: это же фактически реализация принципа «язык под задачу». Просто выбираешь, что тебе удобнее написать на Rust, а что на Python…
codingteam@cjr
Minoru о! Кстати! В продолжение дискуссии про макру python!, встраивающую Python в Rust: это же фактически реализация принципа «язык под задачу». Просто выбираешь, что тебе удобнее написать на Rust, а что на Python…
#prog #rust #python #article
Насколько далеко можно зайти в поддержке кода на Python внутри Rust? Достаточно далеко, чтобы заставить IDE подсвечивать ошибки в коде на Python.
https://blog.m-ou.se/writing-python-inside-rust-3/
Насколько далеко можно зайти в поддержке кода на Python внутри Rust? Достаточно далеко, чтобы заставить IDE подсвечивать ошибки в коде на Python.
https://blog.m-ou.se/writing-python-inside-rust-3/
blog.m-ou.se
Writing Python inside your Rust code — Part 3
Have you ever seen the Rust compiler give a Python error? Or better, have you ever seen rust-analyzer complain about Python syntax? In this post, we’ll extend our python!{} macro to make that happen.
Блог*
#prog #article As closing thoughts: this blog post is not intended to start a flame war, nor is it intended to be an assault on dynamically typed programming. There are many patterns in dynamically-typed languages that are genuinely difficult to translate…
#prog #article
Своеобразное продолжение статьи, даром что автор другой.
"One day you open that module which you haven’t touched in six months, and you see a function call where the third argument is null. You need to remember what kinds of variables you can pass to that third argument, or read the whole source code to figure it out. You follow through the code to see all places that third argument is used and realize the accepted type of the third argument depends on what you give to the second argument. Congratulations, you’re dealing with a dependent type, which means you’ve just surpassed Haskell in terms of type system complexity. Compilers that deal with this kind of type system are so complex they are effectively proof assistants (and are at the forefront of programming language research), and here you are dealing with those data types with your brain (and your faith in your ability to come up with sufficient tests) alone."
https://hisham.hm/2020/01/20/dynamic-type-systems-arent-even-simpler/
Своеобразное продолжение статьи, даром что автор другой.
"One day you open that module which you haven’t touched in six months, and you see a function call where the third argument is null. You need to remember what kinds of variables you can pass to that third argument, or read the whole source code to figure it out. You follow through the code to see all places that third argument is used and realize the accepted type of the third argument depends on what you give to the second argument. Congratulations, you’re dealing with a dependent type, which means you’ve just surpassed Haskell in terms of type system complexity. Compilers that deal with this kind of type system are so complex they are effectively proof assistants (and are at the forefront of programming language research), and here you are dealing with those data types with your brain (and your faith in your ability to come up with sufficient tests) alone."
https://hisham.hm/2020/01/20/dynamic-type-systems-arent-even-simpler/
#rust
Небольшое напоминание (главным образом новичкам, но и остальным тоже): если вы работаете в Rust с текстом в ASCII — пожалуйста, не используйте коды символов напрямую. Для ASCII в Rust есть прекрасные инструменты — байтовые литералы.
Также есть ещё и литералы для байтовых массивов:
Небольшое напоминание (главным образом новичкам, но и остальным тоже): если вы работаете в Rust с текстом в ASCII — пожалуйста, не используйте коды символов напрямую. Для ASCII в Rust есть прекрасные инструменты — байтовые литералы.
b'A'
— это литерал типа u8
, имеющий значение 65, но это куда понятнее, чем 65.Также есть ещё и литералы для байтовых массивов:
assert_eq!(b"hello", &[104, 101, 108, 108, 111]);
Обратите внимание, это именно (статичная) ссылка на массив. Если вам нужно куда-то передавать байтовый слайс, то, возможно, придётся приводит к слайсу явно: &b"hello"[..]
.Forwarded from Идеи неинтересных фильмов
Главный герой - простой австрийский художник, которого по непонятным причинам пытаются убить путешественники во времени.
Forwarded from мне не нравится реальность (Вафель 🧇)
Q: When I was 4, my sister was 2. I am now 44. How old is my sister?
Programmer: 44 - (4 - 2) = 42
Tester:
Programmer: 44 - (4 - 2) = 42
Tester:
Дорогие мои подписчики, я вынужден просить вас о помощи. Пожалуйста, свяжитесь со мной, кто занимался на Rust численными методами решения диффуров.
Писать лучше в @decltype_chat_ptr_t, потому что сообщение в личку я могу банально потерять среди всех моих чатов и каналов
Писать лучше в @decltype_chat_ptr_t, потому что сообщение в личку я могу банально потерять среди всех моих чатов и каналов