Discussion:
[Larceny-users] first steps with Larceny
Michele Simionato
2009-04-19 09:40:55 UTC
Permalink
It is a raining Sunday here in Milan, so I have decided to begin
the porting of my R6RS code to Larceny. I was able to
compile the Larceny SVN trunk on my system (Ubuntu Linux 32 bit)
and basic things seem to work. So, I tried to port my sweet-macros library,
which currently is structured as follow:

sweet-macros
main.sls ;; for ikarus and ypsilon
main.mzscheme.sls
helper1.mzscheme.sls
helper2.mzscheme.sls
helper2.mzscheme.sls
test-all.ss

I thought the only needed change was to copy
the files main.mzscheme.sls, helper1.mzscheme.sls,
helper2.mzscheme.sls, helper2.mzscheme.sls
by substituting mzscheme with larceny; however,
apparently it does not work. Does Larceny look
at the main file in the directory, as it is the case
in all the other R6RS implementations?

I have another question too.
I am writing a compatibility library and I would
like to know from where can I import things
like format, printf ,pretty-print and gensym.
I assume larceny has some internal library
providing these features, but I cannot find it
by skimming the user manual.

Thanks for your help,

Michele Simionato
Eduardo Cavazos
2009-04-19 09:51:20 UTC
Permalink
Post by Michele Simionato
I have another question too.
I am writing a compatibility library and I would
like to know from where can I import things
like format, printf ,pretty-print and gensym.
I assume larceny has some internal library
providing these features, but I cannot find it
by skimming the user manual.
(import (primitives gensym format pretty-print))
Derick Eddington
2009-04-19 10:28:41 UTC
Permalink
Post by Michele Simionato
It is a raining Sunday here in Milan, so I have decided to begin
the porting of my R6RS code to Larceny. I was able to
compile the Larceny SVN trunk on my system (Ubuntu Linux 32 bit)
and basic things seem to work. So, I tried to port my sweet-macros library,
sweet-macros
main.sls ;; for ikarus and ypsilon
main.mzscheme.sls
helper1.mzscheme.sls
helper2.mzscheme.sls
helper2.mzscheme.sls
test-all.ss
I thought the only needed change was to copy
the files main.mzscheme.sls, helper1.mzscheme.sls,
helper2.mzscheme.sls, helper2.mzscheme.sls
by substituting mzscheme with larceny; however,
apparently it does not work.
Well, if they're specific to MzScheme, they're probably not going to
work in Larceny, at least not without reviewing and tweaking some
things. Oh, now I'm remembering your sweet macros, I'm guessing
those .mzscheme.sls are for explicit phasing systems but otherwise
they're not implementation-specific? Remember to configure Larceny's
Post by Michele Simionato
Does Larceny look
at the main file in the directory, as it is the case
in all the other R6RS implementations?
Larceny doesn't support implicit main files. Which at this point I
think is good because Ikarus, PLT, and Ypsilon all do it differently and
we don't want more confusion. My "Library Files" SRFI proposal (still
in progress after discovering a challenging issue related to combined
version constraints) will support a standard for implicit main files
(it's simple and already ready, I believe).
Post by Michele Simionato
I have another question too.
I am writing a compatibility library and I would
like to know from where can I import things
like format, printf ,pretty-print and gensym.
I assume larceny has some internal library
providing these features
Eduardo told you where they're at, but they're not exactly the same as
other implementations'. See my (xitomatl common) library's .larceny.sls
file for what I've done to get a uniform interface.
--
: Derick
----------------------------------------------------------------
Michele Simionato
2009-04-19 12:23:14 UTC
Permalink
On Sun, Apr 19, 2009 at 12:28 PM, Derick Eddington
Post by Derick Eddington
Well, if they're specific to MzScheme, they're probably not going to
work in Larceny, at least not without reviewing and tweaking some
things.  Oh, now I'm remembering your sweet macros, I'm guessing
those .mzscheme.sls are for explicit phasing systems but otherwise
they're not implementation-specific?
Yes, or at least they should be (see later).
Post by Derick Eddington
Larceny doesn't support implicit main files.
I thought so.
Post by Derick Eddington
Eduardo told you where they're at, but they're not exactly the same as
other implementations'.  See my (xitomatl common) library's .larceny.sls
file for what I've done to get a uniform interface.
Ah, I had an old version of xitomatl were common.larceny.sls was missing.
Derick Eddington
2009-04-19 23:47:05 UTC
Permalink
On Sun, 2009-04-19 at 14:23 +0200, Michele Simionato wrote:
Michele Simionato
2009-04-20 04:14:23 UTC
Permalink
On Mon, Apr 20, 2009 at 1:47 AM, Derick Eddington
I know of your
 http://www.phyast.pitt.edu/~micheles/scheme/sweet-macros.zip
but that looks older than the version you described.  Is your latest
version online or would you email it to me?
Here is the code I am using:

$ cat helper1.larceny.sls
#!r6rs
(library (sweet-macros helper1)
(export guarded-syntax-case)
(import (rnrs))

(define-syntax guarded-syntax-case
(let ((add-clause
(lambda (clause acc)
(syntax-case clause ()
((pattern skeleton . rest)
(syntax-case #'rest ()
((cond? else1 else2 ...)
(cons*
#'(pattern cond? skeleton)
#'(pattern (begin else1 else2 ...))
acc))
((cond?)
(cons #'(pattern cond? skeleton) acc))
(()
(cons #'(pattern skeleton) acc))
))))))
(lambda (x)
(syntax-case x ()
((guarded-syntax-case y (literal ...) clause ...)
(with-syntax (((c ...) (fold-right add-clause '() #'(clause ...))))
#'(syntax-case y (literal ...) c ...)))))))
)

$ cat helper2.larceny.sls
#!r6rs
(library (sweet-macros helper2)
(export syntax-match)
(import (rnrs) (for (rnrs) (meta -1))
(for (sweet-macros helper1) expand run (meta -1)))

(define-syntax syntax-match
(lambda (y)
(guarded-syntax-case y (sub)

((self (literal ...) (sub patt skel rest ...) ...)
#'(lambda (x) (self x (literal ...) (sub patt skel rest ...) ...)))

((self x (literal ...) (sub patt skel rest ...) ...)
#'(guarded-syntax-case x (<literals> <patterns> literal ...)
((ctx <literals>) #''(literal ...))
((ctx <patterns>) #''((... (... patt)) ...))
(patt skel rest ...)
...)
(for-all identifier? #'(literal ...))
(syntax-violation 'syntax-match "Found non identifier" #'(literal ...)
(remp identifier? #'(literal ...))))
)))
)

Here is a test that breaks with the "too many ... 's" error:

$ cat test.ss
(import (rnrs) (for (sweet-macros helper2) expand))

(define-syntax m
(syntax-match ()
(sub (_ u ...) #'(list u ...))))

The code runs on Ikarus, Ypsilon and PLT Scheme.
This time I am not surprise, though, since porting
sweet-macros to another R6RS implementation
is *always* an odissey ... :-/
Derick Eddington
2009-04-20 06:18:03 UTC
Permalink
It seems anyway that sweet-macros do not work out of the box with
Larceny (some error "Too many ...'s").
I think the problem is caused by this bug in Larceny:

Larceny v0.97a4 (alpha test) (Apr 19 2009 17:48:52, precise:Linux:unified)
larceny.heap, built on Sun Apr 19 17:50:33 PDT 2009
ERR5RS mode (no libraries have been imported)
(import (rnrs syntax-case))
Autoloading (rnrs syntax-case)
Autoloading (rnrs conditions)
Autoloading (err5rs records procedural)
Autoloading (rnrs exceptions)
(syntax->datum (syntax (... (... foo))))
foo ;; should be (... foo)
--
: Derick
----------------------------------------------------------------
Michele Simionato
2009-04-20 07:13:39 UTC
Permalink
On Mon, Apr 20, 2009 at 8:18 AM, Derick Eddington
Post by Derick Eddington
Larceny v0.97a4 (alpha test) (Apr 19 2009 17:48:52, precise:Linux:unified)
larceny.heap, built on Sun Apr 19 17:50:33 PDT 2009
ERR5RS mode (no libraries have been imported)
(import (rnrs syntax-case))
Autoloading (rnrs syntax-case)
Autoloading (rnrs conditions)
Autoloading (err5rs records procedural)
Autoloading (rnrs exceptions)
(syntax->datum (syntax (... (... foo))))
foo  ;; should be (... foo)
That certainly would break sweet-macros.
FWIW, so far, sweet-macros has been able to find bugs in all
R6RS implementations of syntax-case, except mzscheme
(porting to mzscheme was an odissey too, but not
because of bugs in mzscheme, it was just my ignorance
about how the PLT module system works).
Derick Eddington
2009-04-20 07:44:56 UTC
Permalink
Post by Michele Simionato
On Mon, Apr 20, 2009 at 8:18 AM, Derick Eddington
Post by Derick Eddington
Larceny v0.97a4 (alpha test) (Apr 19 2009 17:48:52, precise:Linux:unified)
larceny.heap, built on Sun Apr 19 17:50:33 PDT 2009
ERR5RS mode (no libraries have been imported)
(import (rnrs syntax-case))
Autoloading (rnrs syntax-case)
Autoloading (rnrs conditions)
Autoloading (err5rs records procedural)
Autoloading (rnrs exceptions)
(syntax->datum (syntax (... (... foo))))
foo ;; should be (... foo)
That certainly would break sweet-macros.
I'm pretty sure it's the problem because, in the below,
((ctx <patterns>) #''((_ u ...)))
is supposed to be
((ctx <patterns>) #''((... (_ u ...))))
Post by Michele Simionato
(import (for (sweet-macros helper2) expand))
Autoloading (sweet-macros helper2)
Autoloading (sweet-macros helper1)
Post by Michele Simionato
(define-syntax m
(syntax-match ()
(sub (_ u ...) #'(list u ...))))

Syntax violation: syntax

Too many ...'s

Form: (u ...)

Trace:

#''((_ u ...))

(syntax-case
x
(<literals> <patterns>)
((ctx <literals>) #''())
((ctx <patterns>) #''((_ u ...)))
((_ u ...) #'(list u ...)))

(lambda (x)
(syntax-match
x
()
(sub (_ u ...) #'(list u ...))))

(syntax-match () (sub (_ u ...) #'(list u ...)))



Error: unhandled condition:
Compound condition has these components:
#<record &who>
who : syntax
#<record &message>
message : "Too many ...'s"
#<record &syntax>
form : (u ...)
subform : #f

Entering debugger; type "?" for help.
debug>
--
: Derick
----------------------------------------------------------------
William D Clinger
2009-04-20 14:13:27 UTC
Permalink
It seems anyway that sweet-macros do not work out of the
box with Larceny (some error "Too many ...'s"). I will
try to nail the issue down to a simple test case.
Thanks to you and Derick for that bug report. It has been
logged as ticket #637.
FWIW, so far, sweet-macros has been able to find bugs in all
R6RS implementations of syntax-case, except mzscheme
This bug is Larceny-specific. Andre van Tonder's macro
expander is not at fault.

Will
William D Clinger
2009-04-20 21:38:58 UTC
Permalink
Post by William D Clinger
This bug is Larceny-specific. Andre van Tonder's macro
expander is not at fault.
I think I was wrong about that.

I have checked in a possible fix that passes all my tests
but may still not be right. Please let me know of any
more bugs you find.

Will

[1] https://trac.ccs.neu.edu/trac/larceny/ticket/637
Michele Simionato
2009-04-21 09:19:38 UTC
Permalink
Post by William D Clinger
This bug is Larceny-specific.  Andre van Tonder's macro
expander is not at fault.
I think I was wrong about that.
I have checked in a possible fix that passes all my tests
but may still not be right.  Please let me know of any
more bugs you find.
I updated svn this morning and recompiled larceny
from scratch, following the rather complex compilation procedure
that worked the first time, but now it seems I have
corrupted the heap file or something like that.
Probably I did something wrong, but I am at work
now and I cannot check. Maybe Derick will report back.

P.S. indeed Larceny is the Scheme implementation
with the more baroque installation procedure I have
seen. Using PLT 4.0 as boostrap compiler did not work,
so I had to install the Larceny binaries to be able to
build the svn version. I would make an effort to
support PLT as bootstrap compiler, since PLT
is the implementation with the easier installation
procedure ever, since it comes as prepackaged
with many Linux distributions (at least with Ubuntu
and Fedora).
Derick Eddington
2009-04-21 13:01:37 UTC
Permalink
Post by Michele Simionato
Post by William D Clinger
Post by William D Clinger
This bug is Larceny-specific. Andre van Tonder's macro
expander is not at fault.
I think I was wrong about that.
I have checked in a possible fix that passes all my tests
but may still not be right. Please let me know of any
more bugs you find.
I updated svn this morning and recompiled larceny
from scratch, following the rather complex compilation procedure
that worked the first time, but now it seems I have
corrupted the heap file or something like that.
Probably I did something wrong, but I am at work
now and I cannot check. Maybe Derick will report back.
I report I was able to build Larceny revision 6186 and these do now
Post by Michele Simionato
(syntax->datum (syntax (... (... foo))))
(... foo)
Post by Michele Simionato
(import (for (sweet-macros helper2) expand))
Autoloading (sweet-macros helper2)
Autoloading (sweet-macros helper1)
Post by Michele Simionato
(define-syntax m
(syntax-match ()
(sub (_ u ...) #'(list u ...))))
Post by Michele Simionato
(m 1 2 3)
(1 2 3)
Post by Michele Simionato
P.S. indeed Larceny is the Scheme implementation
with the more baroque installation procedure I have
seen. Using PLT 4.0 as boostrap compiler did not work,
so I had to install the Larceny binaries to be able to
build the svn version.
I prefer using Larceny to build itself. A Scheme system should build
itself. (But being able to be built by others is neat too.)
Post by Michele Simionato
I would make an effort to
support PLT as bootstrap compiler, since PLT
is the implementation with the easier installation
procedure ever, since it comes as prepackaged
with many Linux distributions (at least with Ubuntu
and Fedora).
If Larceny came prepackaged, it would be equally easy to use for
building new Larcenys. I know those Linux distribution packaging people
love to add new packages as quickly as they can.
--
: Derick
----------------------------------------------------------------
Michele Simionato
2009-04-21 13:06:37 UTC
Permalink
On Tue, Apr 21, 2009 at 3:01 PM, Derick Eddington
Post by Derick Eddington
I report I was able to build Larceny revision 6186 and these do now
(syntax->datum (syntax (... (... foo))))
(... foo)
(import (for (sweet-macros helper2) expand))
Autoloading (sweet-macros helper2)
Autoloading (sweet-macros helper1)
(define-syntax m
   (syntax-match ()
     (sub (_ u ...) #'(list u ...))))
(m 1 2 3)
(1 2 3)
Cool!
Post by Derick Eddington
If Larceny came prepackaged, it would be equally easy to use for
building new Larcenys.
Of course that would be the best option.
Michele Simionato
2009-04-21 17:55:31 UTC
Permalink
On Tue, Apr 21, 2009 at 11:19 AM, Michele Simionato
Post by Michele Simionato
Post by William D Clinger
This bug is Larceny-specific.  Andre van Tonder's macro
expander is not at fault.
I think I was wrong about that.
I have checked in a possible fix that passes all my tests
but may still not be right.  Please let me know of any
more bugs you find.
I updated svn this morning and recompiled larceny
from scratch, following the rather complex compilation procedure
that worked the first time, but now it seems I have
corrupted the heap file or something like that.
Probably I did something wrong, but I am at work
now and I cannot check.
It turns out I was using the wrong LARCENY_ROOT.
It looks like all my test involving sweet-macros are passing,
except the ones using ``format``, since I have yet to convert
them using Derick's suggestion. If don't hear from me,
assume everything is all right!
Another implementation conquered in my path for the
Scheme world domination ...
David Rush
2009-04-22 07:36:47 UTC
Permalink
Post by Michele Simionato
P.S. indeed Larceny is the Scheme implementation
with the more baroque installation procedure I have
seen.
As much as I really like working with Larceny (and that is quite a
lot), I have to agree with you here. Isecond this comment because I am
currently having this pain as well.
Post by Michele Simionato
Using PLT 4.0 as boostrap compiler did not work,
Why? I was putting in a fair bit of effort to getting PLT 4.1.5 to
build on a Debian Etch system, and would prefer to *not* continue
wasting my time.
Post by Michele Simionato
support PLT as bootstrap compiler, since PLT
is the implementation with the easier installation
procedure ever, since it comes as prepackaged
with many Linux distributions (at least with Ubuntu
and Fedora).
Please, no! PLT does *not* have an easy installation procedure in my
book at all, although it's better than it used to be. Right now, PLT
4.1.5 will not build using gcc 4's pre-processor. And since the binary
distro I downloaded from plt-scheme.org has version compatibility
issues with my Etch glibc version. And the PLT package in Etch appears
to be for version 352 (while Larceny require at least v370).

Now Gambit's install:

$ (./configure; make; make install)

That's what I call simple!

david rush
--
GPG Public key at http://cyber-rush.org/drr/gpg-public-key.txt
Michele Simionato
2009-04-22 07:44:54 UTC
Permalink
Post by David Rush
Post by Michele Simionato
P.S. indeed Larceny is the Scheme implementation
with the more baroque installation procedure I have
seen.
As much as I really like working with Larceny (and that is quite a
lot), I have to agree with you here. Isecond this comment because I am
currently having this pain as well.
Post by Michele Simionato
Using PLT 4.0 as boostrap compiler did not work,
Why? I was putting in a fair bit of effort to getting PLT 4.1.5 to
build on a Debian Etch system, and would prefer to *not* continue
wasting my time.
For stupid things, like "if" requiring two branches in PLT 4
(i.e. (if cond then-clause) is invalid syntax), another
thing I forgot and possibly others. Rather than fighting
I installed the larceny binaries.
Post by David Rush
Please, no! PLT does *not* have an easy installation procedure in my
book at all, although it's better than it used to be. Right now, PLT
4.1.5 will not build using gcc 4's pre-processor. And since the binary
distro I downloaded from plt-scheme.org has version compatibility
issues with my Etch glibc version. And the PLT package in Etch appears
to be for version 352 (while Larceny require at least v370).
$ (./configure; make; make install)
That's what I call simple!
Ok. The best would probably be to have a debian/rpm package
with Petit Larceny (I say Petit because I am assuming that
it should be more portable across different architectures,
being an interpreter, but I may be wrong).

Continue reading on narkive:
Loading...