This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: begin at top-level?


Per Bothner <per@bothner.com> writes:
> Because (begin FORM1 FORM2) is the equivalent to FORM1 followed by
> FORM2.

Hmm.  My read of R5RS for non-define forms is that only the value of
FORM2 is returned:

  The <expression>s are evaluated sequentially from left to right, and
  the value(s) of the last <expression> is(are) returned.

> The begin form is kind of funny.  It's a pure syntactic grouping form,
> and is neither a scoping form nor a control form.  It is mainly useful
> for macros, and a few syntax forms like (if ...).
...
> all the variable a, b, c, d are in the same scope.  If they were
> functions they could mutually reference each other.

Sure, but for non-define forms I still expect only the last value to
be returned.  It makes sense to me that 2 is returned here:

  #|kawa:5|# (if #t (begin 1 2) 3)
  2

The problem I have is that we're creating code like this and we expect
only 'b to be returned:

  #|kawa:6|# (define x (eval '(begin 'a 'b)))
  #|kawa:7|# x
  ab

Regards,
Chris Dean


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]