[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

An infix syntax for Scheme ...

From: Jean Abou Samra
Subject: An infix syntax for Scheme ...
Date: Tue, 9 Aug 2022 23:45:41 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0


Some time ago, Jacques Menu asked on the French-speaking equivalent of
this list if it would be possible to create an infix syntax for Scheme
that would be more approachable for beginners.

As we discussed this topic privately and he asked me questions about how
a possible implementation could be done, I ended up finding that an
example was easier to give than full explanations, and this gave "Herescheme":

This is a Git repository. You can also download the code as a .zip archive
using the "Download" button, or from this direct link:

To use Herescheme, download that, unzip it, and \include the file
"/.../herescheme/herescheme.ily". This requires a 2.23 version of
LilyPond (tested with 2.23.11).

There are a number of examples in the file

\relative c' {
  \shape &"[(0, 0), (0, 1.5), (0, 0.4), (0, 0)]" Slur
  \override Beam.grow-direction =
    &"function(beam) =>
        let Y_positions = ly.grob_property(beam, |positions|) in
          ly.message('Beam \\'positions are ~a', Y_positions);
          let left_position = car(Y_positions) in
          let right_position = cdr(Y_positions) in
          if left_position < right_position then {
          else if left_position > right_position then  {
          else if left_position = right_position then {
          else ly.error('this can\\'t happen')
  c'16( d e f g f e d c g c g c e g c)

This is experimental; comments on it are welcome, but I don't recommend
using it for serious projects yet.

To be honest, I have no idea if what I did here is actually a good idea
at all (I for one won't use it). I'm just curious to see. On the one hand,
normal Scheme syntax is used in all Scheme tutorials, in the Guile manuals,
on mailing list snippets, and when printing values, so only using Herescheme
syntax without knowing about basic Scheme syntax is likely tough. On the
other hand, I know Scheme is off-putting to some people just because of its
many parentheses and the "unintuitive" way of placing the operator as prefix.
If that is your case, maybe you'll find Herescheme to your taste. Or maybe

It is possible to mix Scheme and Herescheme code seamlessly.

Also, please note that Herescheme is *not* a whole new language.
Don't expect to be able to write something similar to Java or
Python in LilyPond. Herescheme has the same underlying concepts
as Scheme, is just a different syntax for writing Scheme code.
It does have a syntax that is more familiar to people used to
languages other than from the Lisp family.

Finally, this was just a side project in passing for me, so by
all means do comment, but please don't expect me to update the
code fast.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]