From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: Re: About sweet-expression Date: Mon, 05 Mar 2012 23:35:33 -0500 Message-ID: <87ty22wdm2.fsf@netris.org> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1331008687 14829 80.91.229.3 (6 Mar 2012 04:38:07 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 6 Mar 2012 04:38:07 +0000 (UTC) Cc: guile-devel To: Nala Ginrut Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Mar 06 05:38:06 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1S4mA1-0002jF-2L for guile-devel@m.gmane.org; Tue, 06 Mar 2012 05:38:05 +0100 Original-Received: from localhost ([::1]:43828 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4mA0-0003hs-3t for guile-devel@m.gmane.org; Mon, 05 Mar 2012 23:38:04 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:39964) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4m9w-0003hm-99 for guile-devel@gnu.org; Mon, 05 Mar 2012 23:38:01 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S4m9u-0007yD-92 for guile-devel@gnu.org; Mon, 05 Mar 2012 23:37:59 -0500 Original-Received: from world.peace.net ([96.39.62.75]:47036) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4m9t-0007xp-Ml for guile-devel@gnu.org; Mon, 05 Mar 2012 23:37:58 -0500 Original-Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=yeeloong) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1S4m9i-0002RX-8t; Mon, 05 Mar 2012 23:37:47 -0500 In-Reply-To: (Nala Ginrut's message of "Tue, 6 Mar 2012 11:21:11 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 96.39.62.75 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:14020 Archived-At: Nala Ginrut 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) =C2=A0 > =C2=A0 if {n < 2} =C2=A0 =C2=A0 =C2=A0=C2=A0 > =C2=A0 =C2=A0 n > =C2=A0 =C2=A0 fibup(n 2 1 0) > ----------------------- > But=C2=A0I 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. =C2=A0The author's comment shows that we don't need to=C2=A0re-impleme= nt=C2=A0a > reader if our reader treats "[]" and "{}" as delimiter. =C2=A0But seems " > {}" is not delimiter in current Guile. Mark Weaver said it should be > fixed.=C2=A0 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.=C2=A0 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) =C2=A0 =C2=A0 if {n < 2} =C2=A0 =C2=A0 =C2=A0=C2=A0 =C2=A0 =C2=A0 n =C2=A0 =C2=A0 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:=C2=A0 > {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