5 ms·
> no special syntax for anything. (list '(1. . #\#) -5/6+7.s-8i `(1 ,@2) 1@1 ;hmmm, no unquote splicing comma ;-)
by GregBuchholz 1mo ago
> no special syntax for anything.
(list '(1. . #\#)
-5/6+7.s-8i
`(1 ,@2)
1@1 ;hmmm, no unquote splicing comma ;-)
10# ;surprised?
(list #i+1 +1i 1+i) ;complicated or complex?
#e-1e10i ;Old MacDonald?
"(* 9 10)" #())
- jqpabc123 1mo agoIt looks more like a "program" for an HP15c pocket scientific calculator. Not necessarily a bad thing but also not exactly what I would call "expressive". You may be able to build anything you want --- which may be efficient when communicating with the machine. But I wonder about now well this would communicate with other programmers.
- jibal 1mo agoIt's not a program, it is (obviously) a totally unrealistic hodgepodge expression for a list of constant values that simply demonstrates the literal syntax for a variety of types of values (real numbers, dotted pairs, rational numbers, complex numbers, polar coordinates, etc. -- Racket is unusually expressive in the types of literals). Your comment demonstrates something typical of HN, and it's not a good thing. It's as if in a discussion about C someone posted, without explanation, an entry from the Obfuscated C contest and then someone else, making zero effort to understand what was posted, said that it looked like line noise and questioned whether C is conducive to communication between programmers.
- euduhdhbene 1mo agoFirst time dealing with developers I see. I’m sorry.
- jibal 1mo agoNonsensical non sequitur ad hominem. (FWIW I've been a software developer for 60 years and have dealt with many of them.) I won't respond further.
- euduhdhbene 1mo agoApologies sir, it was uncalled for. The plebeian in me couldn’t resist. I am deeply jaded by my experience, but as you seem to imply your experience is different I am glad for you.
- zelphirkalt 1mo agoI think in this case it is probably justified, as the claim of "no special syntax" is unfortunately not true. To convey the amount of special syntax, it got crammed into one brief example snippet. Still, far less than most other programming languages, virtue of having parentheses making things unambiguous. Outliers are Smalltalk and maybe (?) Forth.
- jibal 1mo ago> I think in this case it is probably justified What is "it"? The GP clearly doesn't understand that code and utterly misconstrues its nature and the nature of the Racket/Scheme/LISP language. If someone has zero knowledge of the topic at hand (even when it's a seminal programming language that's been around for nearly 70 years), they have an obligation to at least glance at TFA before commenting. > the claim of "no special syntax" is unfortunately not true That's a completely different issue than the one I addressed. (And I really don't think the point is made in good faith--the sense in which that phrase was meant is well understood, certainly by the GGP who is so very familiar with Racket's token syntax and quasiquotes.) I won't respond further.
- so-cal-schemer 1mo agoAren't reader macros just a convenient shorthand?
- Joel_Mckay 1mo agoI actually wrote an audio sequencer in HP RPL as a kid. It was far less complex to code, and human readable. Unicon was pretty cool also, but never became popular. Erlang/Elixir will probably become more relevant as people move into massively parallel constraint solvers. The monolith centric languages are simply no longer appropriate for many classes of problems. =3
- jqpabc123 1mo agoUnicon was pretty cool also, but never became popular. Like it or not, popularity is a significant attribute if you have to work with others.
- Joel_Mckay 1mo ago>popularity is a significant attribute if you have to work with others Not sure why people buried your comment, but there is a good argument for long term support. NodeJS is probably the worst to maintain if you cater to the lowest common denominator. Easy to show quick results with a low skill team, but generally anyone that can't be bothered to use other languages is going to cause reliability problems sooner or later. Ecosystems like pip/Cargo/Go-flavor-of-the-year/npm that run out-of-band dependency management will have deferred perpetual IT costs. =3
- nilslindemann 1mo agoCurious, how would look that in Python?
- nilslindemann 1mo agothat look*
- zelphirkalt 1mo agoWould need some imports: import cmath from fractions import Fraction And then have to write numbers as strings to input them. From their examples: >>> Fraction('1.414213 \t\n') Fraction(1414213, 1000000) >>> cmath.sqrt(-2-0j) -1.4142135623730951j Not really great, but workable. I don't like having to import things for basic math stuff like exact numbers, but having a lot of special syntax is maybe also not that great. I am guessing except for maybe macros, there is no other way, if one wants to take input (code) literally as exact numbers in all cases. If one were to just write down a number like `1.414213562373`, and expect it to be exactly represented in the program, then it cannot be read as a floating point number first and then converted into an exact number internally, because reading it as floating point number could already lose precision. So this kind of logic to interpret exact numbers would have to live somewhere before that. So it is in the reader. I am not sure how one could employ a macro instead, and then maybe access the digits of a written number, or whether that is possible. I think it should be possible. If it is, then of course things could be made into macros, after which one could use something like: (exact 1.4142135623730951) [1]: https://docs.python.org/3/library/cmath.html https://docs.python.org/3/library/cmath.html [2]: https://docs.python.org/3/library/fractions.html https://docs.python.org/3/library/fractions.html
- nilslindemann 1mo ago[dead]
- soegaard 1mo agoYeah - the number syntax is pretty cool. #i is the prefix for inexact #e is the prefix for exact So `#e0.1` is exact 0.1 which means it will be read as an exact fraction 1/10 and `#i0.1` will be read as a floating point number. The `i` in `8i` is the imaginary unit. The `1@1` is the polar notation for complex numbers. The `10#` is a compatibility remain (the Scheme authors wanted a way to see how many signifant digits were known. In `10#` there 2. So `#` stands for "some digit". In most implementations this is read as 0. More details at [1] An `#` followed by a list datum is read as a vector. Thus `#()` is an empty vector and `()` is an empty list. [1] https://stackoverflow.com/a/10936403/23567 https://stackoverflow.com/a/10936403/23567 Complicated? Well, to support both inexact (floating point) and exact numbers (bignums and fractions) it makes sense to have `#i` and `#e` to explicitl choose. The default is (more or less): numbers with . are inexact the others are exact.
- Syntonicles 1mo agoAt first I was frustrated by this comment, having a fair amount of Lisp experience failing to grok the examples. In less than one minute I was able to locate, download and install the latest Racket and was in a REPL. There really are no excuses. This was a wild ride. I'm torn on whether this feels like the Reader is bloated/polluted or whether this is the coolest numerical parser I've ever used. You can really do a lot to coerce the these numbers just by inserting an {o,s,e,i,b,#} into the number, with different semantics depending on the position of the character. Somewhat overwhelming, I can only hope there's some elegance underlying it all...
- shawn_w 1mo agoYou forgot hash table and regular expression literals.
- GregBuchholz 1mo agoIt looks like Racket nerfed the shared-structure / "Datum Labels" for circular lists and the like (I see it is still in section 2.4 of r7rs): '#0=(0 . #0#) ...and I should have included `#|block comments|#`, datum `#;comments`, and probably `|symbols with spaces|`. (let ((|1 + 2| (+ 1 2))) (display |1 + 2|))
- soegaard 1mo agoThat has been in Racket for a long time.
- GregBuchholz 1mo agoI tried: #lang racket/base (let ((a '#0=(0 . #0#))) (display (car a))) ...over at https://onecompiler.com/racket https://onecompiler.com/racket ...and it didn't compile, complaining: read-syntax: `#...=` forms not enabled for `read-syntax` mode ...maybe there is a switch needed to enable it?
- soegaard 1mo agoI am not 100% sure what's going on, but you can use `read` mode this way: #lang racket (let ((a (read (open-input-string "#0=(0 . #0#)")))) (display (car a))) I think the problem is that `read` / `write` support shared data constructed using `shared`. But programs (read by `read-syntax` are not allow to have cycles.
- shawn_w 1mo agoYeah, there's a toggle for it in read-syntax mode. https://docs.racket-lang.org/reference/Reading.html#%28def._%28%28quote._~23~25kernel%29._read-syntax-accept-graph%29%29 https://docs.racket-lang.org/reference/Reading.html#%28def._...
- BoingBoomTschak 1mo agoHow did it manage the feat of being more baroque than CL? Why that #e madness instead of https://www.lispworks.com/documentation/HyperSpec/Body/f_ration.htm https://www.lispworks.com/documentation/HyperSpec/Body/f_rat... ?
- liendolucas 1mo agoI think you clearly exposed one of the things that I couldn't never describe why I wasn't dragged into Racket/scheme. It's not only annoying is hard to remember all these differences. Obviously the more you use the language these go away but still at least to me it doesn't seem to be a coherent syntax.
- GregBuchholz 1mo agoWell, to be fair, many/most programs aren't using complex numbers, or concerned with inexact vs. exact numbers, significant digits, or really even scientific notation.
- fweimer 1mo agoIsn't at least one of them undefined? `(1 ,@2) It's always surprising to me how many things Scheme leaves undefined. Other examples are evaluation order (in some rather surprising places) or the value of: (make-bytevector 4)
- soegaard 1mo ago> `(1 ,@2) '(1 . 2) This is a pair. The notations is called "dotted pair".
- fweimer 1mo agoBut 2 isn't a list, and the argument to unqoute-splicing must be a list: > If an (unquote-splicing <expression> ...) form appears inside a <qq template>, then the <expression>s must evaluate to lists; the opening and closing parentheses of the lists are then “stripped away” and the elements of the lists are inserted in place of the unquote-splicing form.
- soegaard 1mo agoSee https://docs.racket-lang.org/reference/quasiquote.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._quasiquote%29%29 https://docs.racket-lang.org/reference/quasiquote.html#%28fo...
- GregBuchholz 1mo agoLooks like fweimer is correct for scheme. I admit to being very surprised. Here is the verbiage from various rXrs: r3rs, r4rs & r5rs (section 4.2.6): https://standards.scheme.org/official/r3rs.pdf https://standards.scheme.org/official/r3rs.pdf https://standards.scheme.org/official/r4rs.pdf https://standards.scheme.org/official/r4rs.pdf https://conservatory.scheme.org/schemers/Documents/Standards/R5RS/r5rs.pdf https://conservatory.scheme.org/schemers/Documents/Standards... "If a comma appears followed immediately by an at- sign (@), then the following expression must evaluate to a list;" r6rs (section 11.17): https://standards.scheme.org/official/r6rs.pdf https://standards.scheme.org/official/r6rs.pdf "If an (unquote-splicing 〈expression〉 . . . ) form appears inside a〈qq template〉, then the〈expression〉s must evaluate to lists;" r7rs (4.2.8): https://standards.scheme.org/official/r7rs.pdf https://standards.scheme.org/official/r7rs.pdf "If a comma appears followed without intervening whitespace by a commercial at-sign (@), then it is an error if the following expression does not evaluate to a list;"