adopting "sweat-expr" reader-extensions for hylang? #2719
goyalyashpal
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
the readable-expressions page lists various improvements to a general lisp-reader - collectively called sweat-expressions.
these most-importantly maintain the homoiconic nature of LISP & are fully backwards compatible (other than infix-exprs for hylang).
other than the infix-expressions, i think that both other can be adopted in hylang reader;
along with making hy more readable to existing devs, these can make it even more easier to approach for devs coming from python.
define factorial(n) if {n <= 1} 1 {n * factorial{n - 1}}(define (factorial n) (if (<= n 1) 1 (* n (factorial (- n 1))))).these are:
fcall-expressions (n-expr):
it enables the math-notation for function calls.
f(arg1 ...)=>(f arg1 ...)infix-expressions (c-expr):
it uses curly braces, which hy already uses for dicts, so can't be used. but otherwise, it's premise is very promising.
{arg1 op arg2 op arg3 op ...}=>(op arg1 arg2 arg3 ...){arg1 op1 {arg2 op2 arg3}}=>(op1 arg1 (op2 arg2 arg3))... no precedence, explicit expressions, alternating arg-op; always!
e.g.:
{a + b + c + ...}=>(+ a b c ...){a - {b / c}}=>(- a {b / c})=>(- a (/ b c)){{a - b} / c}=>(/ {a - b} c)=>(/ (- a b) c)combination of fcall- & infix-:
f{arg1 + arg2}=>f({arg1 + arg2})=>(f (+ arg1 arg2))indent-expressions (t-expr):
it outlines rules for consistently deducing parenthesis from indentation.
Beta Was this translation helpful? Give feedback.
All reactions