2 ms·
With macros, someone can write an infix sublanguage for you to use in those mathy bits of code. Probably better just to get used to prefix notation, though. Ju
by MathMonkeyMan 4y ago
With macros, someone can write an infix sublanguage for you to use in those mathy bits of code.
Probably better just to get used to prefix notation, though. Just pretend everything is a function call.
- WalterBright 4y ago> Just pretend everything is a function call D uses Universal Function Call Syntax, where: f(a) g(f(a)) can be written as: a.f a.f.g It's a very popular feature.
- MathMonkeyMan 4y agoScheme has a shorthand for (cons a b) that's just (a . b), and (cons a (cons b c)) as (a b . c) Racket, a scheme-based language, extended the syntax so that any symbol appearing between two periods and not at the end of a list gets moved to the head of the list, so (a . b . c) becomes (b a c), which some people use so that (a . + . b) becomes (+ a b). The D syntax you describe is what schemes call the "threading macro," or the thrush combinator in non-macro contexts.
- soegaard 4y agoI believe the general consensus is that the double dot notation might not have been the best idea. FWIW it's mostly used for inequalities like `(a . <= . b)` which some people find easier to read than `(<= a b)`. But `<=` allows more arguments as in `(<= a b c d)` and here the double dot notation can't be used.