News for hackers. Stuff that matters.
Re:Learning Clojure: comparing with Java streams by outworlder on Sunday November 04, 2018 @02:26PM (#18377603)
Doesn't Clojure have reader macros? The whole point of lisps is that you can extend them.
Re:Learning Clojure: comparing with Java streams by virmundi on Sunday November 04, 2018 @02:37PM (#18377662)
When I worked with Clojure the community seemed to treat macros as a nuclear option. Only use them when absolutely necessary. For some, this translated to “you can’t hug your children with nuclear arms”. If the community hasn’t changed, perhaps macros out of favor.
Re:Learning Clojure: comparing with Java streams by serpix on Monday November 05, 2018 @01:48AM (#18380377)
This still stands, macros are a really high level abstraction and do not compose. Almost always a function is enough. But if it saves a good chunk of repetition on something complex then go for it.

A good example of code with macro overkill is compojure-api. There is just so many clever macros that you need to read the original source code with a microscope to know what the code expands to.

Re:Learning Clojure: comparing with Java streams by didibus on Sunday November 04, 2018 @03:39PM (#18377962)
Actually, Clojure does not have reader macros, because it was thought to be the biggest cause of the lisp curse.
Re:Learning Clojure: comparing with Java streams by grzm on Sunday November 04, 2018 @03:43PM (#18377973)
Nit: Clojure does not have user-defined reader macros. There are quite a few built-in reader macros, including #? added for reader conditionals.
Re:Learning Clojure: comparing with Java streams by kazinator on Sunday November 04, 2018 @04:28PM (#18378152)
By this definition of terms, every Lisp dialect that ever existed had reader macros because it accumulated characters into tokens, and dispatched a recursive scan upon encountering (.
Re:Learning Clojure: comparing with Java streams by didibus on Sunday November 04, 2018 @09:10PM (#18379341)
Fair enough, though definitly a nitpick :p
Re:Learning Clojure: comparing with Java streams by lispm on Monday November 05, 2018 @01:49AM (#18380383)
Then I'm surprised that it allows the user to define functions and macros.
Re:Learning Clojure: comparing with Java streams by didibus on Monday November 05, 2018 @12:53PM (#18384326)
I think most schemes also don't have reader macros. How often do you actually use them in CL?

I feel reader macros have the problem that it modifies/extend the foundational syntax. And that can become overloaded really quickly. Normal macros can change evaluation semantics, but not the fundamental syntax. Which makes it easier to navigate and understand in general. Also, reader macros are pretty hard to write in comparison.

Racket has a nice take on them though. Making them more like all new programming grammars, and defining your dialect per file. Even there though, most alternate syntax is for research or fun mostly.

Re:Learning Clojure: comparing with Java streams by lispm on Wednesday November 07, 2018 @05:11PM (#18402829)
> I think most schemes also don't have reader macros.

Scheme even has a fixed syntax in the RnRS reports. Lisp does not have that.

> Also, reader macros are pretty hard to write in comparison.

Not really. One just reads things from a stream and returns an s-expression.

> I feel reader macros have the problem that it modifies/extend the foundational syntax

That's a feature.

The main purpose of user-written reader macros is to extend S-expressions to support literal syntax of new user-defined data types.

There is nothing scary about it at all.

> Racket has a nice take on them though. Making them more like all new programming grammars, and defining your dialect per file

My Lisp Machine had that already in the 80s. It supported different language syntax - from various Lisp variants to Pascal, C and other languages.

> Even there though, most alternate syntax is for research or fun mostly.

On my Lisp Machine it was actually useful.

Re:Learning Clojure: comparing with Java streams by didibus on Thursday November 08, 2018 @02:00PM (#18408892)
> Scheme even has a fixed syntax in the RnRS reports. Lisp does not have that.

Could you link to the RnRS in question? I'm curious.

> Not really. One just reads things from a stream and returns an s-expression.

I feel like if I agree to this, I also agree that pre-processors are easy to write and use. And that undermines the innovation and superiority of syntactic macros introduced by Lisp.

> The main purpose of user-written reader macros is to extend S-expressions to support literal syntax of new user-defined data types.

This is possible in Clojure as well. You can extend the language with new data literals. But they must begin with # + char(s) and respect the existing reader semantics, as they are processed as a syntactic macro, and not a lexical one. So you could add #queue[1 2 3] for example. But you couldn't add |1 2 3|

> On my Lisp Machine it was actually useful.

If only they'd still make those, and had improved its performance.

Re:Learning Clojure: comparing with Java streams by lispm on Thursday November 08, 2018 @03:30PM (#18409697)
> Scheme even has a fixed syntax in the RnRS reports. Lisp does not have that.

https://schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-...

> And that undermines the innovation and superiority of syntactic macros introduced by Lisp.

They have a different purpose and operate on a different level.

> respect the existing reader semantics

This is an example of xapping data structure in *Lisp for for the Connection Machine

{moe->"Oh, a wise guy, eh?" larry->"Hey, what's the idea?" curly->"Nyuk, nyuk, nyuk!"}

> If only they'd still make those, and had improved its performance

Nowadays it might be easier to use an emulator running the OS.

Re:Learning Clojure: comparing with Java streams by didibus on Saturday November 10, 2018 @02:52PM (#18423136)
> https://schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-...

Sorry, maybe I'm not seeing it, but what part of that link describe lexical user definable reader macros in scheme?

> {moe->"Oh, a wise guy, eh?" larry->"Hey, what's the idea?" curly->"Nyuk, nyuk, nyuk!"}

Right, so in Clojure you could extend the reader and do:

#xapping{moe "Oh, a wise guy, eh?" larry "Hey, what's the idea?" curly "Nyuk, nyuk, nyuk!"}

As a data literal for xapping data structures.

Re:Learning Clojure: comparing with Java streams by lispm on Sunday November 11, 2018 @03:20PM (#18428356)
> Sorry, maybe I'm not seeing it, but what part of that link describe lexical user definable reader macros in scheme?

None. I never said it does. I said it has a fixed syntax.

Re:Learning Clojure: comparing with Java streams by didibus on Tuesday November 13, 2018 @01:13PM (#18443219)
Oh I see. Okay I misunderstood you.

What do you mean by fixed syntax? A formal syntax?