[plt-scheme] Re: apply vs dot notation syntax

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Sun Oct 5 12:19:29 EDT 2008

On Sun, Oct 5, 2008 at 12:04 PM,  <kbohdan at mail.ru> wrote:
> kbohdan at mail.ru wrote:
>
>> (f a b *: (g c d)) -> (apply f a b (g c d))
>
> Actually i like python function application syntax :
>   f(arg1, arg2, *args, **kwargs)
> where args is a list, and kwargs is a dictionary of keyword arguments.
> Function definition in python can have similar syntax:
>   def f(arg1, arg2, *args, **kwargs):
>       ...
> I understand that this idea is not very applicable to scheme and would like
> to know all reasons for this.

I don't know much about Python.  If args = list(a,b,c) and kwargs =
dict(d=1,e=2), then does f(arg1,arg2,*args,**kwargs) mean
f(arg1,arg2,a,b,c,d=1,e=2)?  If so, then Scheme has about the same
thing as keyword-apply.  You can express (f x y a b c #:d 1 #:e 2) as
(keyword-apply f (list '#:d '#:e) (list 1 2) x y (list a b c)).  The
use of apply or keyword-apply signals that you're not doing direct
application, whereas in Python you look at *s in front of arguments to
figure it out.  Same idea, just slightly different ways of writing it
down.

Does that answer your question?

-- 
Carl Eastlund


Posted on the users mailing list.