unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: Nala Ginrut <nalaginrut@gmail.com>
Cc: guile-devel <guile-devel@gnu.org>
Subject: Re: About sweet-expression
Date: Mon, 05 Mar 2012 23:35:33 -0500	[thread overview]
Message-ID: <87ty22wdm2.fsf@netris.org> (raw)
In-Reply-To: <CAPjoZocFUGenqJ3m=0pPm1XqqmU76ofci+NzVuAzYexw17PQ6A@mail.gmail.com> (Nala Ginrut's message of "Tue, 6 Mar 2012 11:21:11 +0800")

Nala Ginrut <nalaginrut@gmail.com> writes:

> I try to port sweet-expression to newest Guile. Fortunately, the
> author wrote a compatible version for old Guile in 2008. So I just try
> to rewrite part of it for some obvious reasons. It woks fine now.
>
> Though some guys doesn't like sweet-expression at all (OK, they're
> real Lispers! But me too ;-)). I'm not a big fan to write Scheme like
> this:
> -----------------------
> define fibfast(n)  
>   if {n < 2}       
>     n
>     fibup(n 2 1 0)
> -----------------------
> But I think it maybe useful for newbies especially came from Python of
> C. If we can fix the problems which I'll mention later, I expect it to
> be added as inner language support.
>
> I put it here, if you're interested, please checkout here:
> git://gitorious.org/nacre/guile-sweet.git
> It supports Modern & Sugar both. You may read the README and try the
> example.
>
> But there're some problems for the original implementation, so I didn't
> format a patch. I think there should be something to be fixed.
> 1.  The author's comment shows that we don't need to re-implement a
> reader if our reader treats "[]" and "{}" as delimiter.  But seems "
> {}" is not delimiter in current Guile. Mark Weaver said it should be
> fixed. 

Yes, it would be good to at least have a reader option to treat {} as
delimiters.  I haven't looked carefully at this, but I suspect the main
requirement is to stop reading when we reach a '}', and furthermore to
unget that delimiter when we reach it.

Without this, the sweet expression reader will need to reimplement the
entire reader from scratch, which seem suboptimal for several reasons.

> 2. And the second suggestion of Mark Weaver is we *must* try the Guile
> inner reader tools and keep some information if there's errors
> happened. I think it's a more worthy consideration. The current sweet
> is too weak to be a productive thing. 

To clarify, I was talking about the need to set source properties on the
datums that are read.  However, having thought a bit more about this,
it's clear that Guile's reader can be of very little help here.

The sweet expression reader itself must be responsible for setting
source properties on all the resulting lists that are not written with
normal parentheses.  For example, in the following sweet expression:

  define fibfast(n)  
    if {n < 2}       
      n
      fibup(n 2 1 0)

Guile's reader is of no help at all with source properties.
Fortunately, Guile provides all of the interfaces you need to do this
job from Scheme: 'set-source-properties!', 'port-filename', 'port-line'
and 'port-column'.  This will have to be implemented in the sweet
expression reader.

> 3. We don't have "nfx" macro in current Guile, so only simple infix
> expression can be evaluated. Say, all the operators are homologous: 
> {1 + 2 + 3} is simple infix expression
> {1 + 2 - 3} is not.
> Anyway, it's not a big deal, I'll fix it later. But I'm not sure
> whether it should be in Guile or in app? Since the author use "nfx"
> directly, maybe it's a common thing we missed?

It seems clear to me that David Wheeler intended for 'nfx' to be defined
by the user, to implement whatever operator precedence they wish for
their particular module.  There's no universally good 'nfx' macro.

    Thanks,
      Mark



  parent reply	other threads:[~2012-03-06  4:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-06  3:21 About sweet-expression Nala Ginrut
2012-03-06  3:22 ` Nala Ginrut
2012-03-06  4:35 ` Mark H Weaver [this message]
2012-03-12 17:17   ` Nala Ginrut
2012-03-12 19:05     ` Mark H Weaver
2012-03-13  2:01       ` Nala Ginrut
2012-03-13  3:51         ` Nala Ginrut
2012-04-12  1:53           ` Nala Ginrut
2012-03-06  6:42 ` David Kastrup
2012-03-06  8:16   ` Nala Ginrut
2012-03-12 16:47     ` Nala Ginrut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ty22wdm2.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=guile-devel@gnu.org \
    --cc=nalaginrut@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).