GNU bug report logs - #16363
interactive use subject to compiler limitations

Previous Next

Package: guile;

Reported by: Zefram <zefram <at> fysh.org>

Date: Sun, 5 Jan 2014 23:45:14 UTC

Severity: normal

Tags: notabug

To reply to this bug, email your comments to 16363 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#16363; Package guile. (Sun, 05 Jan 2014 23:45:14 GMT) Full text and rfc822 format available.

Acknowledgement sent to Zefram <zefram <at> fysh.org>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Sun, 05 Jan 2014 23:45:15 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Zefram <zefram <at> fysh.org>
To: bug-guile <at> gnu.org
Subject: interactive use subject to compiler limitations
Date: Sun, 5 Jan 2014 23:17:59 +0000
guile-2.0.9's compiler has some inconvenient restrictions, relative to
its interpreter.  Where the compiler is automatically applied to scripts,
the restrictions aren't a serious problem, because if compilation fails
then guile falls back to interpreting the script.  But in an interactive
REPL session, by default each form entered by the user is passed through
the compiler, and if compilation fails then the error is signalled,
with no fallback to interpretation.

As a test case, consider a form in which a procedure object appears.
The compiler can't handle forms that directly reference a wide variety of
object types, including procedures (both primitive and user-defined) and
GOOPS objects.  In the interpreter these objects simply self-evaluate,
and it can be useful to reference them without the usual indirection
through a named variable.  Here I'll show what happens to such a form
in a script and interactively, in guile 1.8 and 2.0:

$ cat t2
(cond-expand
  (guile-2
    (eval-when (compile load eval)
      (fluid-set! read-eval? #t)))
  (else
    (fluid-set! read-eval? #t)))
(define (p x y) (#.+ x y))
(write (p 2 3))
(newline)
$ guile-1.8 t2
5
$ guile-2.0 --no-auto-compile t2
5
$ guile-2.0 t2
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /home/zefram/usr/guile/t2
;;; WARNING: compilation of /home/zefram/usr/guile/t2 failed:
;;; ERROR: build-constant-store: unrecognized object #<procedure + (#:optional _ _ . _)>
5
$ guile-1.8
guile> (fluid-set! read-eval? #t)
guile> (define (p x y) (#.+ x y))
guile> (p 2 3)
5
guile> ^D
$ guile-2.0
GNU Guile 2.0.9-deb+1-1
Copyright (C) 1995-2013 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (fluid-set! read-eval? #t)
scheme@(guile-user)> (define (p x y) (#.+ x y))
While compiling expression:
ERROR: build-constant-store: unrecognized object #<procedure + (#:optional _ _ . _)>
scheme@(guile-user)> (p 2 3)
<unnamed port>:3:0: In procedure #<procedure 12bc9e0 at <current input>:3:0 ()>:
<unnamed port>:3:0: In procedure #<procedure 12bc9e0 at <current input>:3:0 ()>: Unbound variable: p

There is a workaround for this problem: the REPL's "interp" option
controls whether forms go through the compiler or the interpreter.  Hence:

scheme@(guile-user)> (fluid-set! read-eval? #t)
scheme@(guile-user)> (#.+ 2 3)
While compiling expression:
ERROR: build-constant-store: unrecognized object #<procedure + (#:optional _ _ . _)>
scheme@(guile-user)> ,o interp #t
scheme@(guile-user)> (#.+ 2 3)
$1 = 5

So the problem is merely that the REPL is broken *by default*.
It should either default to the working mechanism, or fall back to it
when compilation fails (as the file auto-compilation does).

Debian incarnation of this bug report:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=734108

-zefram




Information forwarded to bug-guile <at> gnu.org:
bug#16363; Package guile. (Wed, 15 Jan 2014 20:06:01 GMT) Full text and rfc822 format available.

Message #8 received at 16363 <at> debbugs.gnu.org (full text, mbox):

From: Mark H Weaver <mhw <at> netris.org>
To: Zefram <zefram <at> fysh.org>
Cc: 16363 <at> debbugs.gnu.org, request <at> debbugs.gnu.org
Subject: Re: bug#16363: interactive use subject to compiler limitations
Date: Wed, 15 Jan 2014 15:03:29 -0500
tags 16363 notabug
thanks

Zefram <zefram <at> fysh.org> writes:

> guile-2.0.9's compiler has some inconvenient restrictions, relative to
> its interpreter.  Where the compiler is automatically applied to scripts,
> the restrictions aren't a serious problem, because if compilation fails
> then guile falls back to interpreting the script.  But in an interactive
> REPL session, by default each form entered by the user is passed through
> the compiler, and if compilation fails then the error is signalled,
> with no fallback to interpretation.
>
> As a test case, consider a form in which a procedure object appears.
> The compiler can't handle forms that directly reference a wide variety of
> object types, including procedures (both primitive and user-defined) and
> GOOPS objects.  In the interpreter these objects simply self-evaluate,
> and it can be useful to reference them without the usual indirection
> through a named variable.

Scheme does not allow arbitrary user objects to be embedded directly
into the source code.  It worked by accident in Guile 1.8, but in a
system with ahead-of-time compilation to object files, which requires
that all code and literals be serialized, there's no sane way to support
the semantics you seem to want.

     Regards,
       Mark




Added tag(s) notabug. Request was from Mark H Weaver <mhw <at> netris.org> to control <at> debbugs.gnu.org. (Wed, 15 Jan 2014 20:06:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-guile <at> gnu.org:
bug#16363; Package guile. (Wed, 15 Jan 2014 21:27:02 GMT) Full text and rfc822 format available.

Message #13 received at 16363 <at> debbugs.gnu.org (full text, mbox):

From: Zefram <zefram <at> fysh.org>
To: Mark H Weaver <mhw <at> netris.org>
Cc: 16363 <at> debbugs.gnu.org
Subject: Re: bug#16363: interactive use subject to compiler limitations
Date: Wed, 15 Jan 2014 21:26:29 +0000
Mark H Weaver wrote:
>that all code and literals be serialized, there's no sane way to support
>the semantics you seem to want.

We've addressed the semantics themselves on the other ticket, #16362.
Accepting that the compiler semantics are preferred, there's still a
problem in the scope of my intent for this ticket #16363: that interactive
behaviour doesn't match the behaviour of a script.  The mismatch is a
problem for development regardless of which set of semantics is correct.

As I mentioned in passing on the other ticket, you could fix this by
enforcing the compiler restrictions in interpreting situations.  A start
on this would be for read-eval to refuse to accept any object without a
readable print form, such as the procedure in my example on this ticket.
For objects that do have a readable print form, such as the pair in
#16362, it could break the referential identity by copying the object,
as if by printing it to characters and reading it back.

If, on the other hand, you actually intend for the compiler and
interpreter to have visibly different semantics, there's still the
problem that the REPL approaches that difference in a different way from
script execution.  In that case, either the REPL should perform the same
fallback that script execution does (as I originally suggested on this
ticket), or script execution should not perform the fallback.

-zefram




Information forwarded to bug-guile <at> gnu.org:
bug#16363; Package guile. (Wed, 02 Jun 2021 14:46:03 GMT) Full text and rfc822 format available.

Message #16 received at 16363 <at> debbugs.gnu.org (full text, mbox):

From: Adriano Peluso <randomlooser <at> riseup.net>
To: 16363 <at> debbugs.gnu.org
Subject: is this still current ?
Date: Wed, 02 Jun 2021 09:35:51 +0200
Can this issue be closed ?





This bug report was last modified 2 years and 351 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.