Re: Backquote simplification

2010-12-11 Thread Hans Aberg

On 11 Dec 2010, at 01:25, Neil Jerram wrote:


The reply I got was helpful, but I decided to settle for a macro
implementation:

(use-syntax (ice-9 syncase))

(define-syntax tuple
 (syntax-rules ()
   ((tuple xs ...)
`(tuple ,xs ...))
   ((tuple x1 x2 . y)
(append `(tuple ,x1 ,x2) y))
   ((tuple x1 . y)
(append `(tuple ,x1) y))
))


OK, I roughly see that this solves your problem of wanting to  
unquote an
arbitrary number of list elements.  (Although I don't understand why  
you

need to do that.)


One reason is that in the normal syntax f(x_1, ..., x_k) there are two  
separate parts f and (x_1, ..., x_k) that are combined, whereas in  
Scheme it is combined to one (f x_1 ... x_k) and does not have a  
concept for the (x_1, ..., x_k). Another is that it is needed in the  
translation of expressions like f(g(x)) --> (f (g x)), and (f g)x -->  
((f g) x).



It behaves as I want in my context, a functional language on top of
Guile.


Scheme is already a functional language, isn't it?


I am using Bison/Flex parser/lexer to generate a different syntax. It  
turns out to be a good help not having to implement the back-end.



I decided to implement the construct (lambda (x_1 ... x_k . y)
f)


What syntax is that expression in?  In Scheme syntax, it's a lambda  
that

returns a value that is apparently unrelated to any of the arguments,
and so could equally well be written as (lambda ignored-args f).


I implement it using Guile C calls, and when constructing using
scm_list_3(scm_sym_lambda, x, f), it turns out that x = (x_1 ... x_k .  
y) is an improper list.



using an improper list (x_1 ... x_k . y); when it is a proper list,
one just gets the fixed number of arguments construct.

Then the object (x_1 ... x_k . y) also become available, so it is
possible to form
 (define f (lambda (x_1 ... x_k . y) (x_1 ... x_k . y)))


How is this different from

 (define f (lambda args args))

?


The form (x_1 ... x_k . y) is an improper list that requires at least  
k arguments, and the rest given arguments are put into y as a list.



Then one would expect f(a_1, ..., a_n), for n >= k, to be (a_1, ...,
a_n) - this a form of the identity.

So to get this effect, I need a function g that can call improper
lists (g x_1, ..., x_k . y), where y is a list.


As Dan pointed out, that is not an improper list.  It's a proper list.


That would be true if the evaluator does not try to evaluate the  
expression before the substitution of y. That works in the case of a  
freestanding (g x_1 ... x_k . y), but for some reason not in the form

  (lambda (x_1 ... x_k . y) (g x_1 ... x_k . y))

I do not know why.

In the hope that these questions might be useful to at least one of  
us...


I do not know what that means.




Re: Backquote simplification

2010-12-11 Thread Neil Jerram
Hi Hans,

To reply quickly to one point in your email...  (I'll ponder the rest
later.)

Hans Aberg  writes:

> On 11 Dec 2010, at 01:25, Neil Jerram wrote:
>
>> In the hope that these questions might be useful to at least one of
>> us...
>
> I do not know what that means.

I meant that I'm sure I don't understand yet what you're doing, and
hence that the answers might help me; and that there was a possibility
that you might not be understanding some things, and that in that case
the discussion might help you too.

Regards,
Neil



Re: Backquote simplification

2010-12-11 Thread Hans Aberg

On 11 Dec 2010, at 11:01, Neil Jerram wrote:


To reply quickly to one point in your email...  (I'll ponder the rest
later.)


Whenever you so want.


In the hope that these questions might be useful to at least one of
us...


I do not know what that means.


I meant that I'm sure I don't understand yet what you're doing, and
hence that the answers might help me; and that there was a possibility
that you might not be understanding some things, and that in that case
the discussion might help you too.


Yes, the replies are helpful, though I am programming also directly  
with Guile C calls involving unevaluated expressions.





Demo program guile(1.8.7) Win32(XP) C++ g++( 4.3.4) cygwin(1.7.7-1) UNICODE tortoise (integrated console)

2010-12-11 Thread objc
Any interest in any of the above keywords ?
I wrote it, should I publish it ?

Interested in knowing if people use MSwindows and guile much ?

regards,

objcjohn