unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mike Gerwitz <mikegerwitz@gnu.org>
To: Nala Ginrut <nalaginrut@gmail.com>
Cc: guile-devel@gnu.org
Subject: Re: REPL reader of multi-language
Date: Fri, 30 May 2014 08:48:46 -0400	[thread overview]
Message-ID: <20140530124846.GA1969@fencepost.gnu.org> (raw)
In-Reply-To: <1401438340.26418.33.camel@Renee-desktop.suse>

[-- Attachment #1: Type: text/plain, Size: 1479 bytes --]

On Fri, May 30, 2014 at 04:25:40PM +0800, Nala Ginrut wrote:
> It's not a problem for Ecmascript, because its statement has to be ended
> with semicolon. So it's easier to detect the minimum compiling unit in
> REPL. 

ECMAScript uses semicolon insertion---semicolons are optional, but this can
lead to ambiguities. For example:

  function foo() {
    return
      { foo: "bar" }
  }

`foo` will return undefined, not {foo:"bar}, because it inserts a semi-colon
after `return`; the way to get around this is to put the beginning curly
brace of the object literal on the same line as `return`, in which case the
expression would be completed by the closing curly brace of the object
literal, semicolon optional.

If you take a look at Node.js' REPL, you can see how it handles line
continuations.

So this problem would exist for more than just Lua. But is it actually a
problem? Ctrl+D, if needed to end an expression, would represent EOF; I
don't know if this is valid in Lua, but in ES, if an EOF (or semicolon) is
encountered during the parsing of an expression that requires more input,
then it is a syntax error---the compiler and REPL would handle it in the
same way, but the REPL would just display a PS2-style prompt (which readline
seems to do as "..." right in Guile 2.0).

It could be my ignorance of Lua. :)

-- 
Mike Gerwitz
Free Software Hacker | GNU Maintainer
http://mikegerwitz.com
FSF Member #5804 | GPG Key ID: 0x8EE30EAB

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2014-05-30 12:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-30  8:25 REPL reader of multi-language Nala Ginrut
2014-05-30 12:48 ` Mike Gerwitz [this message]
2014-06-03  6:58   ` Nala Ginrut
2014-05-30 19:08 ` Ludovic Courtès
2014-06-03  6:36   ` 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=20140530124846.GA1969@fencepost.gnu.org \
    --to=mikegerwitz@gnu.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).