5 ms·
Or from foo.x to (foo-x foo) or print(a, b, c, d) to (print (a) (b) (c) (d)) I don't think it's the end of the world, but I'm pretty sure one ca
by jstimpfle 4y ago
Or from
foo.x
to
(foo-x foo)
or
print(a, b, c, d)
to
(print (a) (b) (c) (d))
I don't think it's the end of the world, but I'm pretty sure one can make solid physiological arguments why the first is a little easier to read.
If it wasn't, how come math notation relies heavily on infix operators and even subscripts, superscripts and more? It's because you want to optimize notation for the frequently used stuff.
- yoro46 4y agoReally instead it's (accessor object) and (print arg-1 arg-2 ... arg-n) No idea why you suddenly converted the values a, b, c, d to full-blown forms. But of course, baby duck syndrome will prevail and Minsky's comments are painfully true to this day: "Anyone can learn it [Lisp syntax] in a day, unless they know Fortran, in which case it's three days." P.S. Making general comments about "math notation" is pretty dishonest argument. The math I studied was all commutative diagrams and blobs to represent manifolds; very little "infix operators" as far as I could tell. Mathematicians in general are flexible with notation (and definitions!) and will normally default to whatever is the loose consensus in their field :)
- wiseowise 4y ago> But of course, baby duck syndrome will prevail and Minsky's comments are painfully true to this day: "Anyone can learn it [Lisp syntax] in a day, unless they know Fortran, in which case it's three days." That’s hilarious, where did he say that?
- Jtsummers 4y agoI'm only finding the quote, no source. But here's something we can be sure he said: > The complete syntax of LISP can be learned in an hour or so; the interpreter is compact and not exceedingly complicated, and students often can answer questions about the system by reading the interpreter program itself. https://web.media.mit.edu/~minsky/papers/TuringLecture/TuringLecture.html https://web.media.mit.edu/~minsky/papers/TuringLecture/Turin...
- deleted 4y ago[deleted]
- jstimpfle 4y agoNo need to throw offenses. See my cousin comment for an explanation.
- bmacho 4y ago> P.S. Making general comments about "math notation" is pretty dishonest argument. The math I studied was all commutative diagrams and blobs to represent manifolds; very little "infix operators" as far as I could tell. Mathematicians in general are flexible with notation (and definitions!) and will normally default to whatever is the loose consensus in their field :) It is exactly the point of what you are answering: mathematicians too use a flexible, ad-hoc notation. Presumably it is better for them. I don't see how it is dishonest, I find it quiet on point. I guess it needs less ink/chalk, and gives more visual clue about the structure and the content of the equation, than a more uniform, lisp like notation would.
- jdminhbg 4y agoYour second example isn't right, you've added an extra layer of parens. It's either (print a b c d) or your pre-translation should be print(a(), b(), c(), d()).
- jstimpfle 4y agoMy thought here is that a, b, c, d are expression placeholders (and assuming they don't contain commas in the ALGOL syntax version). It's (print a b c d) if all arguments to the ALGOL version are already terminal symbols. If instead it was print(foo.a, foo.b, foo.c, x + y) it's now (print (get-a foo) (get-b foo) (get-c foo) (+ x y)).
- SighMagi 4y ago(print (a) (b) (c) (d)) would be print(a(), b(), c(), d())
- Jach 4y agoI agree you can make arguments, I like your explanation for the final form further downthread. For the second form, another choice could be (.x foo) or (. foo x). Or if you're trying to write something like System.out.println("x"), Clojure's .. shows it could be written as (.. System out (println "x")). Or, if you're using CL, you can use the access library (https://github.com/AccelerationNet/access https://github.com/AccelerationNet/access) and write things like #Dfoo.bar.bast or (with-dot () (do-thing whatever.thing another.thing)). In trying to further steelman a case where random Lisp syntax can be more difficult to read than, say, equivalent Python, two other areas come to mind. First is the inside-outness order of operations thing, it trips people up sometimes. Like the famous "REPL" (with a bad printer) is just (loop (print (eval (read)))), but in English we want to see that as LPER. Solutions include things like the arrow macro (Clojure did good work on showcasing it and other simple macros that can resolve this issue in many places) and if you write/pull one into CL REPL becomes (-> (read) (eval) (print) (loop)), how nice to read. But even the ancient let/let* forms allow you to express a more linear version of something, and you can avoid some instances of the problem with just general programming taste on expression complexity (an issue with all languages -- https://grugbrain.dev/#grug-on-expression-complexity https://grugbrain.dev/#grug-on-expression-complexity shows one form). The second area is on functions that have multiple exit points. A lot of Lispers seem to just not like return-from, and will convert things into cond expressions or similar or just say no to early exits and it can make things a bit more awkward. The solution here I think comes from both ends, the first is a broader cultural norm spreading in other languages against functions with multiple return statements and getting used to code written that way, the other is to just not get so upset about return-from and use it when it makes the code nicer to read.
- yyyk2 4y ago> how come math notation relies heavily on infix operators and even subscripts, superscripts and more? "Mathematical notation" is an ad-hoc compilation of a huge number of historical accidents, conventions and personal preferences. For each function in math, there's at least 3 different notations for it, and somehow each of your professors ends up using a different one. And to counter your argument, prefix operators appear very frequently in mathematics, including the most common function notation (although of course there's also a postfix and an infix notation), sigma notation, quantificators, roots, and many other common operators. By the way, your second example should be (print a b c d), I'm not sure why you made a,b,c,d functions there.