From: globalrev
Subject: def app = apply, problem
Date: 
Message-ID: <2ccf9189-85bb-4254-95c0-6c1ca1780104@c65g2000hsa.googlegroups.com>
instead of:
CL-USER> (apply #'+ '(1 2 3))
6

i want to do:
(app + (1 2 3))


(def app (oper expr)
	   (apply #'oper 'expr))

doesnt work though, i get
CL-USER> (app + (3 4)) 3 is not a function name

(app + '(3 4))
FUNCTION: undefined function OPER
   [Condition of type SYSTEM::SIMPLE-UNDEFINED-FUNCTION]


(app + (3 4)) gives 3 not a function name if:
(def app (oper expr)
     (funcall #'oper expr))

From: Tim Bradshaw
Subject: Re: def app = apply, problem
Date: 
Message-ID: <36cab159-398f-4502-95f0-cbb464fd7832@e39g2000hsf.googlegroups.com>
On Apr 29, 5:34 pm, globalrev <·········@yahoo.se> wrote:
> instead of:
> CL-USER> (apply #'+ '(1 2 3))
> 6
>
> i want to do:
> (app + (1 2 3))
>
> (def app (oper expr)
>            (apply #'oper 'expr))
>

(defmacro app (op &rest args) `(apply (function ,op) ,@args)))

I'll leave it to others to explain why the whole idea is ill-
conceived.
From: Chris Russell
Subject: Re: def app = apply, problem
Date: 
Message-ID: <e47a94a4-07a4-4683-92e3-853ff25ded51@b1g2000hsg.googlegroups.com>
On 29 Apr, 17:34, globalrev <·········@yahoo.se> wrote:
> instead of:
> CL-USER> (apply #'+ '(1 2 3))
> 6
>
> i want to do:
> (app + (1 2 3))
 Have you thought about writing (+ 1 2 3) instead? You'll be saving 5
characters.
From: John Thingstad
Subject: Re: def app = apply, problem
Date: 
Message-ID: <op.uadt5pwkut4oq5@pandora.alfanett.no>
P� Tue, 29 Apr 2008 18:34:31 +0200, skrev globalrev <·········@yahoo.se>:

> instead of:
> CL-USER> (apply #'+ '(1 2 3))
> 6
>
> i want to do:
> (app + (1 2 3))
>
>
> (def app (oper expr)
> 	   (apply #'oper 'expr))
>
> doesnt work though, i get
> CL-USER> (app + (3 4)) 3 is not a function name
>
> (app + '(3 4))
> FUNCTION: undefined function OPER
>    [Condition of type SYSTEM::SIMPLE-UNDEFINED-FUNCTION]
>
>
> (app + (3 4)) gives 3 not a function name if:
> (def app (oper expr)
>      (funcall #'oper expr))

#'<> really is just short for (function <>)
You need that in the original expression or + will be evaluated.
Evaluating + means get last command..

So you would need a defmacro to make sure app doesn't get evaluated before  
the substitution takes place.

(defmacro app (operation argument-list)
   `(apply ',operation ,argument-list))

Why do you wish not to quote the operation but wish to quote the list?

You don't really need a new function for this as it does the same thing.

(setf (symbol-macro (intern "APP")) #'apply)

> (app #'+ '(1 2 3))
6

or

(defun alias (name function &optional (package *package*))
   (setf (symbol-macro (intern (string-upcase name) package)) function))


--------------
John Thingstad
From: globalrev
Subject: Re: def app = apply, problem
Date: 
Message-ID: <dd9b3343-c098-415e-8b98-bb1c019408fc@w74g2000hsh.googlegroups.com>
On 29 Apr, 19:14, "John Thingstad" <·······@online.no> wrote:
> På Tue, 29 Apr 2008 18:34:31 +0200, skrev globalrev <·········@yahoo.se>:
>
>
>
> > instead of:
> > CL-USER> (apply #'+ '(1 2 3))
> > 6
>
> > i want to do:
> > (app + (1 2 3))
>
> > (def app (oper expr)
> >       (apply #'oper 'expr))
>
> > doesnt work though, i get
> > CL-USER> (app + (3 4)) 3 is not a function name
>
> > (app + '(3 4))
> > FUNCTION: undefined function OPER
> >    [Condition of type SYSTEM::SIMPLE-UNDEFINED-FUNCTION]
>
> > (app + (3 4)) gives 3 not a function name if:
> > (def app (oper expr)
> >      (funcall #'oper expr))
>
> #'<> really is just short for (function <>)
> You need that in the original expression or + will be evaluated.
> Evaluating + means get last command..
>
> So you would need a defmacro to make sure app doesn't get evaluated before
> the substitution takes place.
>
> (defmacro app (operation argument-list)
>    `(apply ',operation ,argument-list))
>
> Why do you wish not to quote the operation but wish to quote the list?
>
> You don't really need a new function for this as it does the same thing.
>
> (setf (symbol-macro (intern "APP")) #'apply)
>
> > (app #'+ '(1 2 3))
>
> 6
>
> or
>
> (defun alias (name function &optional (package *package*))
>    (setf (symbol-macro (intern (string-upcase name) package)) function))
>
> --------------
> John Thingstad

i dont want to quote the expr, i just want to write (app + (1 2 3))
for example.

(setf (symbol-macro (intern "APP")) #'apply)  doesnt work on SBCL.


(defmacro app (operation argument-list)
    `(apply ',operation ,argument-list))
does though when qoting the list.





(defmacro app (op &rest args) `(apply (function ,op) ,@args)))  doesnt
work either in cbsl.
READ from #1=#<INPUT STRING-INPUT-STREAM>: an object cannot start with
#\)
   [Condition of type SYSTEM::SIMPLE-READER-ERROR]
From: Pascal J. Bourguignon
Subject: Re: def app = apply, problem
Date: 
Message-ID: <7cod7r3jh9.fsf@pbourguignon.anevia.com>
globalrev <·········@yahoo.se> writes:
> (defmacro app (op &rest args) `(apply (function ,op) ,@args)))  doesnt
> work either in cbsl.
> READ from #1=#<INPUT STRING-INPUT-STREAM>: an object cannot start with
> #\)
>    [Condition of type SYSTEM::SIMPLE-READER-ERROR]

Please, read the error message.  What does it tell you?

-- 
__Pascal Bourguignon__
From: John Thingstad
Subject: Re: def app = apply, problem
Date: 
Message-ID: <op.uadulnhiut4oq5@pandora.alfanett.no>
P� Tue, 29 Apr 2008 19:14:03 +0200, skrev John Thingstad  
<·······@online.no>:

> (setf (symbol-macro (intern "APP")) #'apply)

Opps! that should be symbol-function.

--------------
John Thingstad
From: Pascal J. Bourguignon
Subject: Re: def app = apply, problem
Date: 
Message-ID: <7cwsmg36ia.fsf@pbourguignon.anevia.com>
globalrev <·········@yahoo.se> writes:

> instead of:
> CL-USER> (apply #'+ '(1 2 3))
> 6
>
> i want to do:
> (app + (1 2 3))
>
>
> (def app (oper expr)
> 	   (apply #'oper 'expr))
>
> doesnt work though, i get
> CL-USER> (app + (3 4)) 3 is not a function name
>
> (app + '(3 4))
> FUNCTION: undefined function OPER
>    [Condition of type SYSTEM::SIMPLE-UNDEFINED-FUNCTION]
>
>
> (app + (3 4)) gives 3 not a function name if:
> (def app (oper expr)
>      (funcall #'oper expr))

What is def?


(defmacro app (operator arguments) `(,operator ,@arguments))


But then you cannot do the equivalent of:

(let ((op (if (oddp (random 2)) '+ '-)))
   (apply op '(29 3)))

(let ((op (if (oddp (random 2)) '+ '-)))
   (app op (29 3))) ; breaks.

and on the other hand, if you already know the operator and arguments (app + (1 2 3))
why not just write: (+ 1 2 3) ?


 

-- 
__Pascal Bourguignon__
From: globalrev
Subject: Re: def app = apply, problem
Date: 
Message-ID: <7deac0ab-bd13-4e0a-b005-c21386af64bf@8g2000hse.googlegroups.com>
On 29 Apr, 19:39, ····@informatimago.com (Pascal J. Bourguignon)
wrote:
> globalrev <·········@yahoo.se> writes:
> > instead of:
> > CL-USER> (apply #'+ '(1 2 3))
> > 6
>
> > i want to do:
> > (app + (1 2 3))
>
> > (def app (oper expr)
> >       (apply #'oper 'expr))
>
> > doesnt work though, i get
> > CL-USER> (app + (3 4)) 3 is not a function name
>
> > (app + '(3 4))
> > FUNCTION: undefined function OPER
> >    [Condition of type SYSTEM::SIMPLE-UNDEFINED-FUNCTION]
>
> > (app + (3 4)) gives 3 not a function name if:
> > (def app (oper expr)
> >      (funcall #'oper expr))
>
> What is def?
>
> (defmacro app (operator arguments) `(,operator ,@arguments))
>
> But then you cannot do the equivalent of:
>
> (let ((op (if (oddp (random 2)) '+ '-)))
>    (apply op '(29 3)))
>
> (let ((op (if (oddp (random 2)) '+ '-)))
>    (app op (29 3))) ; breaks.
>
> and on the other hand, if you already know the operator and arguments (app + (1 2 3))
> why not just write: (+ 1 2 3) ?
>
> --
> __Pascal Bourguignon__

i dont know the operator and its merely educational anyway.
From: Alex Mizrahi
Subject: Re: def app = apply, problem
Date: 
Message-ID: <4817731b$0$90264$14726298@news.sunsite.dk>
 g> i dont know the operator

so you'll be calling passing a variable: (app op (1 2 3))
won't it be easier to use (funcall op 1 2 3)?

Common Lisp already has large set of functions, operators and macros that 
make sense.
most of stuff you can invent will make no sense OTOH

 g> and its merely educational anyway.

rather than inventing random "stuff", it would be much more educational to 
try to emulate various special operators/macros via a limited set of other 
ones:

emulate if via cond (and vice versa)

let* via let

labels via flet (this is quite challenging)
...