Re: [Chicken-hackers] CR: (#439) quasiquote changes

2010-12-11 Thread Alaric Snell-Pym
On 12/10/10 22:09, John Cowan wrote:
> Thomas Chust scripsit:
>
>> few Scheme compilers would report (cons (x)) as a compile time error
>> for lack of static type information.
>
> You don't need any, unless you are prepared to handle reassigning (as
> opposed to rebinding) the name.  As long as cons is not locally rebound,
> you know it takes two arguments, and if it is locally rebound, you still
> know how many arguments it takes if it is bound to a lambda, and can
> blow it off if it is not.  If that counts as static type information,
> it's a pretty minimal variety.

I would also be concerned about how to efficiently implement this...

If (foo (a) (b) (c)) is to be compiled without values-splicing, it's
easy enough to arrange for the return value of (a) to end up wherever
the first argument of (foo ...) should go, and so on.

With value-splicing, unless we can tell in advance (through difficult
analysis) how many values each of (a), (b) and (c) return, we'd need to
collect them together at run time and then put them into the activation
record for (foo ...).

ABS

--
Alaric Snell-Pym
http://www.snell-pym.org.uk/alaric/

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-hackers


Re: [Chicken-hackers] CR: (#439) quasiquote changes

2010-12-10 Thread John Cowan
Thomas Chust scripsit:

> few Scheme compilers would report (cons (x)) as a compile time error
> for lack of static type information.

You don't need any, unless you are prepared to handle reassigning (as
opposed to rebinding) the name.  As long as cons is not locally rebound,
you know it takes two arguments, and if it is locally rebound, you still
know how many arguments it takes if it is bound to a lambda, and can
blow it off if it is not.  If that counts as static type information,
it's a pretty minimal variety.

> Obviously, if enough static type information was present, it would be
> easy to check whether (x) actually returned exactly two values 

That's actually not possible unless you have static knowledge of *every*
procedure.

-- 
Overhead, without any fuss, the stars were going out.
--Arthur C. Clarke, "The Nine Billion Names of God"
John Cowan 

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-hackers


Re: [Chicken-hackers] CR: (#439) quasiquote changes

2010-12-10 Thread Thomas Chust
2010/12/10 John Cowan :
> Thomas Chust scripsit:
>
>> to me the analogy seems quite well chosen. By the way, sometimes I
>> actually wonder whether splicing behaviour of multiple values in an
>> argument list wouldn't be a good idea, but I'm unsure.
>
> It's a Really Bad Idea, because it makes it impossible, for example, to
> report (cons (x)) as a compile-time error (too few arguments). After
> all, what if x returns two values?

Hello John,

few Scheme compilers would report (cons (x)) as a compile time error
for lack of static type information.

Obviously, if enough static type information was present, it would be
easy to check whether (x) actually returned exactly two values and
(cons (x)) was valid.

So yes, splicing return values is probably a better idea in a language
more strongly typed than traditional Scheme.

Ciao,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-hackers


Re: [Chicken-hackers] CR: (#439) quasiquote changes

2010-12-10 Thread Christian Kellermann
* John Cowan  [101210 21:42]:
> Thomas Chust scripsit:
> 
> > to me the analogy seems quite well chosen. By the way, sometimes I
> > actually wonder whether splicing behaviour of multiple values in an
> > argument list wouldn't be a good idea, but I'm unsure.
> 
> It's a Really Bad Idea, because it makes it impossible, for example, to
> report (cons (x)) as a compile-time error (too few arguments). After
> all, what if x returns two values?

I am confused by that. How cdoes this work?

Thanks,

Christian

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-hackers


Re: [Chicken-hackers] CR: (#439) quasiquote changes

2010-12-10 Thread John Cowan
Thomas Chust scripsit:

> to me the analogy seems quite well chosen. By the way, sometimes I
> actually wonder whether splicing behaviour of multiple values in an
> argument list wouldn't be a good idea, but I'm unsure.

It's a Really Bad Idea, because it makes it impossible, for example, to
report (cons (x)) as a compile-time error (too few arguments). After
all, what if x returns two values?

-- 
John Cowan  co...@ccil.org   http://www.ccil.org/~cowan
Dievas dave dantis; Dievas duos duonos  --Lithuanian proverb
Deus dedit dentes; deus dabit panem --Latin version thereof
Deity donated dentition;
  deity'll donate doughnuts --English version by Muke Tever
God gave gums; God'll give granary  --Version by Mat McVeagh

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-hackers


Re: [Chicken-hackers] CR: (#439) quasiquote changes

2010-12-10 Thread Felix
From: Thomas Chust 
Subject: Re: [Chicken-hackers] CR: (#439) quasiquote changes
Date: Fri, 10 Dec 2010 12:27:51 +0100

> 2010/12/8 Peter Bex :
>> [...]
>> I find this _very_ weird.  It feels as if they made (+ (values 1 2 3))
>> be identical to (+ 1 2 3) - sorry if that's a weird analogy, but it's
>> exactly the same to my brain.
> 
> Hello,
> 
> to me the analogy seems quite well chosen. By the way, sometimes I
> actually wonder whether splicing behaviour of multiple values in an
> argument list wouldn't be a good idea, but I'm unsure.

Never.


cheers,
felix

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-hackers


Re: [Chicken-hackers] CR: (#439) quasiquote changes

2010-12-10 Thread Thomas Chust
2010/12/8 Peter Bex :
> [...]
> I find this _very_ weird.  It feels as if they made (+ (values 1 2 3))
> be identical to (+ 1 2 3) - sorry if that's a weird analogy, but it's
> exactly the same to my brain.

Hello,

to me the analogy seems quite well chosen. By the way, sometimes I
actually wonder whether splicing behaviour of multiple values in an
argument list wouldn't be a good idea, but I'm unsure.

> [...]
> Quasiquote itself is not allowed to have multiple arguments,
> which is also a bit inconsistant (but logical).  Racket does allow
> multiple nested arguments to quasiquotes.  I haven't been able to test
> with any other r6rs Scheme because Racket is the only one available in
> pkgsrc and I'm not willing to mess around with building one from source.
> Extra data points would be appreciated if someone else reading this
> happens to have another r6 implementation at hand.
> [...]

Here are the results with two other R6RS implementations:

  Petite Chez Scheme 8.0:

> (let ([a 0] [b 1] [c 2])
(quasiquote ((unquote a b c
(0 1 2)

> (let ([a 0] [b 1] [c 2])
(quasiquote (unquote a b c)))
(unquote a b c)

> (let ([a 0] [b 1] [c 2])
(quasiquote (quasiquote (unquote a b c
`(unquote a b c)

> (let ([a 0] [b 1] [c 2])
(quasiquote (unquote a) (unquote b) (unquote c)))
Exception: invalid syntax (quasiquote (unquote a) (unquote b) (unquote c))

  Ypsilon 0.9.6-update3

> (let ([a 0] [b 1] [c 2])
(quasiquote ((unquote a b c
(0 1 2)

> (let ([a 0] [b 1] [c 2])
(quasiquote (unquote a b c)))

error in quasiquote: unquote appear in bad context

  >  `(unquote a b c)
  ..."/dev/stdin" line 2
  @  (unquote a b c)
  ..."/dev/stdin" line 2

> (let ([a 0] [b 1] [c 2])
(quasiquote (quasiquote (unquote a b c
`(unquote a b c)

> (let ([a 0] [b 1] [c 2])
(quasiquote (unquote a) (unquote b) (unquote c)))
0

I'd say, the behviour is not exactly consistent between
implementations.

Ciao,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-hackers


Re: [Chicken-hackers] CR: (#439) quasiquote changes

2010-12-09 Thread Peter Bex
On Tue, Dec 07, 2010 at 12:46:29PM +0100, Peter Bex wrote:
> R5RS explicitly mentions that nested quasiquote, unquote or
> unquote-splicing calls in positions other than the head of a proper
> list which contains two elements is undefined and can lead to
> strange behaviour:
> http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-7.html#%_sec_4.2.6

I checked R6RS, which extends the unquote/unquote-splicing syntaxes
to allow for multiple arguments:
http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-14.html#node_sec_11.17

However, this is rather non-untuitive IMO:

(let ((a 1) (b 2) (c 3))
  (quasiquote ((unquote a b c => (1 2 3)

It's like unquote also sort-of splices its arguments into the containing
list.  In other words, it's identical to

(let ((a 1) (b 2) (c 3))
  (quasiquote ((unquote a) (unquote b) (unquote c => (1 2 3)

I find this _very_ weird.  It feels as if they made (+ (values 1 2 3))
be identical to (+ 1 2 3) - sorry if that's a weird analogy, but it's
exactly the same to my brain.

Also, I'm unclear as to what happens when you leave off the outer
parentheses:

(let ((a 1) (b 2) (c 3))
  (quasiquote (unquote a b c))) => ; error?

If I interpret the spec correctly, it says the implementation should
throw an error in this case.  Testing with Racket confirms this.
However, (quasiquote (quasiquote (unquote a b c)))  is accepted by
Racket, but that doesn't seem correct if I understand the spec.
The quotation grammar in the spec doesn't make much sense to me though,
so maybe someone can help out in explaining it?

Quasiquote itself is not allowed to have multiple arguments,
which is also a bit inconsistant (but logical).  Racket does allow
multiple nested arguments to quasiquotes.  I haven't been able to test
with any other r6rs Scheme because Racket is the only one available in
pkgsrc and I'm not willing to mess around with building one from source.
Extra data points would be appreciated if someone else reading this
happens to have another r6 implementation at hand.

Anyway, I'd like to add:

Option 7:
Do it the R6RS way.  We'd have to flesh out what exactly happens when
you do (quasiquote (quasiquote a b c)) or similar, and what happens when
you pass multiple arguments to unquote in a non-list context.


BTW, I also checked R7 but couldn't find anything related to quotation
on their lists.

Cheers,
Peter
-- 
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music."
-- Donald Knuth

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-hackers