Modern Programming
-
Argument?
You know, the stuff in @_
-
Are you just referring to how Python uses the English
and
/or
instead of the more common&&
/||
? I think what the user above you was talking about was Lua's strange ternary syntax usingand
/or
.wrote on last edited by [email protected]no, the linked table shows how python also returns the first non-falsey result of an
a or b
expression rather than just giving a boolean. it's useful for initialising optional reference args:def foo(a: list = None) a = a or []
works with
and
as well. -
For optimal performance, you should rewrite it in Rust:
inline_python::python! { print(js2py.eval_js("(number) => number % 2 ? 'odd' : 'even'")(number)) };
wrote on last edited by [email protected]And now you can use wasm to run it in a browser!
-
And now you can use wasm to run it in a browser!
Full circle
-
Please. That's C's ternary operator. JS is just a pile of garbage cosplaying as a programming language
Why do you say it's a pile of garbage?
-
The ternary syntax is really my only real gripe with python design -- putting the conditional BETWEEN the true and false values feels so very messy to me.
wrote on last edited by [email protected]Eh, reads pretty naturally to me. That said,
(like I lisp)
-
It's kinda natural to me having used Perl a lot.
wrote on last edited by [email protected]You clearly haven't used Perl a lot. Perl's ternary looks like:
$even = $num % 2 ? "nay" : "yay";
Incidentally, it is also the same as PHP's, but mainly because PHP stole it.
-
Eh, reads pretty naturally to me. That said,
(like I lisp)
Oh, (you) (really) (like) (Lisp)?
(That's) (great!) -
Eh, reads pretty naturally to me. That said,
(like I lisp)
Lisps makes more sense to me though
(if condition a b)
VS
a if condition else b
-
Why do you say it's a pile of garbage?
Because of all the garbage
-
You clearly haven't used Perl a lot. Perl's ternary looks like:
$even = $num % 2 ? "nay" : "yay";
Incidentally, it is also the same as PHP's, but mainly because PHP stole it.
You do get the if in the middle of stuff though in the form print(debug message) if $debug
-
Full circle
Make sure the browser is made using Rust and run on a VM running on Linux, compiled to WASM.
-
This post did not contain any content.
Just send pseudo code to AI and compile straight to binary.
-
You do get the if in the middle of stuff though in the form print(debug message) if $debug
Wait until you learn that postfix conditionals are syntactic sugar and the compiler* turns that line into the equivalent of
$debug and print(debug message)
, putting the conditional in first place, a lot like the ternary operator.* Perl compiles to bytecode before running.
The ternary operator itself isn't implemented in terms of
and
(andor
) but it could be. -
Wait until you learn that postfix conditionals are syntactic sugar and the compiler* turns that line into the equivalent of
$debug and print(debug message)
, putting the conditional in first place, a lot like the ternary operator.* Perl compiles to bytecode before running.
The ternary operator itself isn't implemented in terms of
and
(andor
) but it could be.Luckily I don't need to read or write bytecode and all that matters to me is the syntax
-
Because of all the garbage
Clearly the garbage collector is too effective
-
Lisps makes more sense to me though
(if condition a b)
VS
a if condition else b
I was more talking about
(+ a b)
and such. -
The ternary syntax is really my only real gripe with python design -- putting the conditional BETWEEN the true and false values feels so very messy to me.
At least you guys have ternary syntax cries in kotlin.
-
You clearly haven't used Perl a lot. Perl's ternary looks like:
$even = $num % 2 ? "nay" : "yay";
Incidentally, it is also the same as PHP's, but mainly because PHP stole it.
perl -e 'print "fart\n" if 1;'
-
You know, the stuff in @_
heheh. I wasn't really making an argument though