- 1
Питушня #19
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
Питушня #19
#1: https://govnokod.ru/26692 https://govnokod.xyz/_26692
#2: https://govnokod.ru/26891 https://govnokod.xyz/_26891
#3: https://govnokod.ru/26893 https://govnokod.xyz/_26893
#4: https://govnokod.ru/26935 https://govnokod.xyz/_26935
#5: (vanished) https://govnokod.xyz/_26954
#6: (vanished) https://govnokod.xyz/_26956
#7: https://govnokod.ru/26964 https://govnokod.xyz/_26964
#8: https://govnokod.ru/26966 https://govnokod.xyz/_26966
#9: https://govnokod.ru/27017 https://govnokod.xyz/_27017
#10: https://govnokod.ru/27045 https://govnokod.xyz/_27045
#11: https://govnokod.ru/27058 https://govnokod.xyz/_27058
#12: https://govnokod.ru/27182 https://govnokod.xyz/_27182
#13: https://govnokod.ru/27260 https://govnokod.xyz/_27260
#14: https://govnokod.ru/27343 https://govnokod.xyz/_27343
#15: https://govnokod.ru/27353 https://govnokod.xyz/_27353
#16: https://govnokod.ru/27384 https://govnokod.xyz/_27384
#17: https://govnokod.ru/27482 https://govnokod.xyz/_27482
#18: https://govnokod.ru/27514 https://govnokod.xyz/_27514
+1
function *foo()
{
yield 1;
yield 2;
yield 3;
}
function main()
{
for (const o of foo())
{
console.log (o);
}
}
main();
давайте посмотрим, как TS/JS имплементирует "елды". изначально код выглядит красиво. но заглянем под капот что генерит tsc для выполнение такого кода. мне придется разбить этот ужос
+1
struct file_id
{
uint64_t persistent;
uint64_t volatile_;
static const size_t RAW_LENGTH = 16;
operator std::string() const
{ return std::string(reinterpret_cast<const char*>(&persistent), RAW_LENGTH); }
// Операторы для использования file_id в качестве ключа map и
// unordered_map
struct hash
{
std::size_t operator()(const ntdec_smb2_file_id& file_id) const
{
std::string s_file_id = file_id;
std::hash<std::string> hasher;
return hasher(s_file_id);
}
};
bool operator == (const ntdec_smb2_file_id& other)
{
return std::string(*this) == std::string(other);
}
bool operator < (const ntdec_smb2_file_id& other)
{
return std::string(*this) < std::string(other);
}
bool operator > (const ntdec_smb2_file_id& other)
{
return std::string(*this) > std::string(other);
}
};
operator std::string тоже UB?
+1
type a = 1;
type i = a & a;
type j = a | a;
function main() {
let v1: i;
let v2: j;
assert(sizeof(i) != sizeof(j));
print("done.");
}
ну все я понял вам скучно... как насчет такого примера?
+1
fn main() {
println!("Hello World!");
}
rustc --version --verbose:
rustc 1.52.1 (9bc8c42bb 2021-05-09)
binary: rustc
commit-hash: 9bc8c42bb2f19e745a63f3445f1ac248fb015e53
commit-date: 2021-05-09
host: powerpc-unknown-linux-gnu
release: 1.52.1
LLVM version: 12.0.0
Error output
rustc ./hello.rs
Illegal instruction (core dumped)
https://github.com/rust-lang/rust/issues/85238
Open: clienthax opened this issue on May 12 · 6 comments
+1
C 5.2s gcc test.c
C++ 1m 25s g++ test.cpp
Zig 10.1s zig build-exe test.zig
Nim 45s nim c test.nim
Rust Stopped after 30 minutes rustc test.rs
Swift Stopped after 30 minutes swiftc test.swift
D Segfault after 6 minutes dmd test.d
Rust and Swift took too long to compile 400k lines, so I tried smaller numbers:
# lines Rust Swift D
2k 3.4s 0.8s
4k 9.0s 1.0s
8k 30.8s 2.3s
20k 3m 52s 11.8s 4.7s
100k - 5m 57s segfault
https://vlang.io/compilation_speed
+1
QSqlQuery& SQLConnect::get()
{
if ( makeConnection() ) {
query = QSqlQuery(mDb);
return query;
}
QSqlQuery empty;
return empty;
}
bool SQLConnect::makeConnection()
{
mDb = SQLConnectPool::Instance().get();
return true;
}
Раньше компилилось и не замечал, а тут на новом компиляторе начал кидать ошибки и решил посмотреть, что же там напроектировали
+1
function foo(arg: any) {
if (typeof arg === "string") {
// We know this is a string now.
print(<string>arg);
}
}
function main() {
foo("Hello");
foo(1);
print("done.");
}
я вам новый говнокодец притарабанил.... вот будете как настоящие жабаскриптеры в нативе
+1
10 лет назад читала самоучитель по Паскалю, где были задания: "написать алгоритм для нахождения простых чисел до n",
"написать 2D-пушку (на CRT модуле)".
Сейчас хочется найти его, вспомнить свое детство (задолго до того, как пошла формошлепить хех).
Ничего похожего пока не нашла.
+1
function main() {
let user = {
firstName: "John",
sayHi() {
print(`Hello, ${this.firstName}!`);
},
};
user.sayHi();
print("done.");
}
как тебе такое Илон Маск?