News for hackers. Stuff that matters.
Re:What Template Haskell gets wrong and Racket gets right by dleslie on Monday July 18, 2016 @02:38PM (#12117177)
FYI, Racket's syntax macros is from its Scheme roots. For further information on what Scheme provides, by standard revision:

R5RS: [0]

R6RS: [1]

R7RS: [2] (Page 22)

And many Schemes provide non-standard extensions; for instance, Chicken supports non-hygienic macros[3].

FWIW, I prefer to think of the two stages as "syntax expansion" and "evaluation", and not "compile time" and "run time". Compilation and running are loaded terms that don't appropriately capture the totality of situations where this behaviour applies, in Scheme.

0: http://schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-8...

1: http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-14.html#node_se...

2: http://trac.sacrideo.us/wg/raw-attachment/wiki/WikiStart/r7r...

3: http://wiki.call-cc.org/explicit-renaming-macros

Re:What Template Haskell gets wrong and Racket gets right by madmax96 on Monday July 18, 2016 @04:07PM (#12117747)
I strongly dislike Racket's macro system, from my admittedly limited usage of it.

Does Racket have a way to address the need to, say, create a dispatching table during syntax expansion and read from that table at runtime? I don't know Racket well, but I've been able to do similar things easily in Guile, Common Lisp, and Clojure without an issue. Googling this problem leads me to believe that it can't be done, which is a pretty severe handicap to have if you're a Lisp.

Re:What Template Haskell gets wrong and Racket gets right by samth on Monday July 18, 2016 @04:16PM (#12117799)
Yes, you can certainly do that in Racket. For example, the `case` macro does exactly that when there are many possibilities. Unless you mean something different that I mean by "create and then read from".
Re:What Template Haskell gets wrong and Racket gets right by madmax96 on Monday July 18, 2016 @04:24PM (#12117845)
Ah. It seems I have misunderstood some of the Racket documentation. Thanks for the comment -- helped me out:)

Also adding that what I was doing in Guile, Common Lisp, and Clojure was sloppy. After searching for the case macro, saying 'aha!', and applying what I learned into creating an equivalent Racket macro, I realize that it was a portable solution to Guile, and the same idea applies for non-hygienic macro systems.

Re:What Template Haskell gets wrong and Racket gets right by gus_massa on Monday July 18, 2016 @06:21PM (#12118370)
If you send a minimized example to the mailing list, I'm sure someone will translate it from Guile to Racket in a few hours. https://groups.google.com/forum/#!forum/racket-users

(If the example is not too long, perhaps you can paste it here.)

Re:What Template Haskell gets wrong and Racket gets right by stchang on Monday July 18, 2016 @02:57PM (#12117313)
FWIW, the phase system that is the main topic of the article was created for Racket [1], though some Scheme macro systems have since adopted this Racket innovation.

[1]: https://www.cs.utah.edu/plt/publications/macromod.pdf

Re:What Template Haskell gets wrong and Racket gets right by brudgers on Monday July 18, 2016 @04:32PM (#12117898)
Racket also has the concept of a documentation phase. Matthew Flatt wished it into existence when creating Scribble.
Re:What Template Haskell gets wrong and Racket gets right by dleslie on Monday July 18, 2016 @06:29PM (#12118401)
Re:What Template Haskell gets wrong and Racket gets right by samth on Monday July 18, 2016 @08:42PM (#12118836)
I think it (like Guile) just supports the reader syntax, rather than the semantics (which is heavily based on Racket's macro system).
Re:What Template Haskell gets wrong and Racket gets right by ezyang on Monday July 18, 2016 @02:41PM (#12117198)
Note that R7RS does not really have any sort of sophisticated phase system for macros.
Re:What Template Haskell gets wrong and Racket gets right by hellofunk on Monday July 18, 2016 @02:55PM (#12117295)
What exactly is the difference between Racket and Scheme, how are they related?
Re:What Template Haskell gets wrong and Racket gets right by ioddly on Monday July 18, 2016 @03:00PM (#12117342)
Racket is derived from Scheme. Sometime after R6RS I believe they decided to just call their own not-necessarily compatible language Racket, but Racket can also run RxRS scheme code.

http://racket-lang.org/new-name.html

Re:What Template Haskell gets wrong and Racket gets right by nilved on Monday July 18, 2016 @03:43PM (#12117597)
Racket was formerly PLT Scheme, but it became such a superset of R6RS that it is now considered its own language. However, I believe it has options for Scheme compatibility.
Re:What Template Haskell gets wrong and Racket gets right by brudgers on Monday July 18, 2016 @04:37PM (#12117927)
The big differences in my experience are defaulting to immutability and embracing the idea of being a big language...so big that Racket is many languages, not just one.
Re:What Template Haskell gets wrong and Racket gets right by spraak on Monday July 18, 2016 @05:05PM (#12118054)
This is tangentially related but it seems like you might know - I heard something about a big vs small release of R7RS? Do you know anything about that?
Re:What Template Haskell gets wrong and Racket gets right by jdmichal on Monday July 18, 2016 @05:41PM (#12118214)
Scheme has traditionally had a minimalist philosophy about the language itself. Basically, the language defines only very low-level syntax and operations -- think arithmetic, variable and function definition, basic control flow, etc. It was then up to libraries to add additional functionality.

R7RS small maintains this same mentality. R7RS big is basically R7RS small with a large standard library.

Re:What Template Haskell gets wrong and Racket gets right by _delirium on Monday July 18, 2016 @06:01PM (#12118302)
And as political background, this is basically the "we'll offer both options" resolution to the R6RS acrimony. R6RS tried to take the language in a more "batteries included" direction, which led to a lot of resistance from some quarters, and was part of why Racket ended up disclaiming itself as being a Scheme and going in its own direction (the Racket team was quite involved in R6RS, and I believe stung by the way it was essentially rejected by a big part of the Scheme community). R7RS-small is sort of a spiritual successor to R5RS, and R7RS-large is trying to carry on what R6RS attempted, but in a way that can be factored out of R7RS-small and used to complement it.

The problem people have been trying to work through is that many people like a small, clean, minimalist core Scheme, but many other people (well, some are the same people, myself included) don't think the current standard is enough to produce useful interoperability. Especially implementors like being able to write small self-hosted experimental or embedded Schemes without a large standard. But many people writing Scheme code are not all that happy about the poor interoperability story that ends up resulting, because there is not quite enough standardized to write libraries that will work on all the major schemes, which is why there's no Scheme equivalent of CL's Quicklisp repository of cross-implementation libraries (the SFRI system is the only real attempt to make this sort-of happen, and is not really good enough).

Re:What Template Haskell gets wrong and Racket gets right by spraak on Monday July 18, 2016 @11:56PM (#12119499)
Thanks so much for your very detailed explanation! With interop, do you mean FFI?

For R7RS-large, are there plans for a module standard?

Re:What Template Haskell gets wrong and Racket gets right by _delirium on Tuesday July 19, 2016 @03:34AM (#12120357)
Maybe interop isn't quite the right term. I meant being able to write portable Scheme code, something that can run on, say, both Guile and Bigloo. The current standard leaves so much undefined that most practical Scheme code is nonportable.
Re:What Template Haskell gets wrong and Racket gets right by dleslie on Monday July 18, 2016 @06:30PM (#12118409)
Well said.

And yet, R7RS-large _still_ will not have a standardized FFI.

Re:What Template Haskell gets wrong and Racket gets right by qwertyuiop924 on Monday July 18, 2016 @08:09PM (#12118722)
You actually CAN'T have a standard FFI, without having a blessed implementation, as so much of FFI is implementation specific. Besides, it would force FFIs in scheme to do The Right Thing to handle continuations (many don't). And call/cc is expensive enough as it is.
Re:What Template Haskell gets wrong and Racket gets right by dleslie on Monday July 18, 2016 @11:37PM (#12119408)
There are many languages without blessed implementations that define ways to interoperate with other languages. For instance: C++[0], Haskell[1], Java[2], Common Lisp[3], and others[4]. The FFI needn't describe how Scheme structures should behave, it need only describe how to send and receive data that a foreign library can interpret; IE, C data structures.

0: http://en.cppreference.com/w/cpp/language/language_linkage

1: https://www.haskell.org/onlinereport/haskell2010/haskellch8....

2: https://docs.oracle.com/javase/8/docs/technotes/guides/jni/

3: https://common-lisp.net/project/cffi/

4: https://en.wikipedia.org/wiki/Foreign_function_interface#Exa...

Re:What Template Haskell gets wrong and Racket gets right by qwertyuiop924 on Tuesday July 19, 2016 @08:25AM (#12121301)
Alright. I didn't know. But I will say that Scheme is a particularly hard language to build an FFI for. In order to do The Right Thing, and have continuations work across language boundries, you have to integrate continuations into a system that is gleefully unaware of their existance. Depending on the design decisions made, making the FFI do The Right Thing is either impossible, or painfully expensive. So many implementations don't. The only thing RnRS could do is define as implementation inspecific an API as possible, and define any use with continuations undefined behaviour. And that would only be moderately better than not having them at all.
Re:What Template Haskell gets wrong and Racket gets right by dleslie on Tuesday July 19, 2016 @05:36PM (#12125119)
Why should continuations need to safely work across language boundaries? Plenty of Schemes support FFIs with the enormous warning that call/cc exists and you should be aware of that.

This solution is hugely superior to having none at all; as it means that bindings to foreign libraries may trivially be ported across many Schemes. Choosing the right Scheme will be less about what libraries are available, and more about which provides the best execution environment for your needs.

In this case, doing the right thing happens to be doing nothing more than warning the user, as is often the case. Attempting to design a system that safely captures foreign state with continuations is almost certainly an over-engineered solution.

Re:What Template Haskell gets wrong and Racket gets right by qwertyuiop924 on Tuesday July 19, 2016 @09:23PM (#12126232)
Actually, you're right. God, what was I thinking. The only potential problem is that implementations that DO implement callcc across ffi will wind up with code that won't run on implementations that DON'T. That would be bad, but not the end of the world. The real problem is that it's unlikely such a thing would be standardized.
Re:What Template Haskell gets wrong and Racket gets right by sitkack on Monday July 18, 2016 @05:57PM (#12118283)
R7RS would have to been an extraction, because big came first. That is probably the way to do things

  1. kitchen sink
  2. extract core
  3. redefine kitchen sink as `small` + extras
Re:What Template Haskell gets wrong and Racket gets right by jdmichal on Tuesday July 19, 2016 @10:10AM (#12121856)
R7RS-small was ratified back in July 2013, while R7RS-big still isn't ratified.
Re:What Template Haskell gets wrong and Racket gets right by sitkack on Tuesday July 19, 2016 @09:10PM (#12126184)
That is great news. I remember when they got announced, -big was first with -small to follow.