Question re CL need of funcall ?

lisp

    Next

  • 1. prototype instances
    Does anyone know if the hyper spec mentions prototype instances? In particular I'm wondering what the initialization protocol is, and how the prototype instances is effected by updated-instance-for-redefined-class. -jim

Question re CL need of funcall ?

Postby fireblade » Wed, 19 Jul 2006 03:41:32 GMT

After being exposed to Scheme : through converting SICP code to Common
Lisp
I wonder why CL decided to use funcall .
For example
If fn is an function as argument , like

(defun baz (fn x)
   (funcall fn x))

couldn't compiler insert funcall when it sees fn after opening bracket
so this would be the same as above :

(defun baz (fn x)
   (fn x))

(baz #'1+ 2)


Re: Question re CL need of funcall ?

Postby Pascal Costanza » Wed, 19 Jul 2006 04:15:33 GMT



This is a FAQ. Google for Lisp-1 and Lisp-2.


Pascal

-- 
My website:  http://www.**--****.com/ 
Closer to MOP & ContextL:
 http://www.**--****.com/ 

Re: Question re CL need of funcall ?

Postby Barry Margolin » Wed, 19 Jul 2006 09:51:55 GMT

In article < XXXX@XXXXX.COM >,




Consider:

(defun baz (list x)
  (list list x))

If it automatically inserted funcall, this would call the wrong function.

MACLisp had an option to do the automatic funcall if the name at the 
beginning of an expression doesn't have a function binding, but AFAIK no 
one ever turned on the option.

-- 
Barry Margolin,  XXXX@XXXXX.COM 
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***

Similar Threads:

1.why funcall is needed in things like ((foo) 10)

2.simple funcall question

I've been playing with Lisp a bit to get a hang of the basics. In one
app I have a list of assorted items, some of which are functions that
may need to get called later. But I'm missing something in my syntax
to make it work.  I've reduced the question to:

  CL-USER> (funcall #'(lambda () (format t "called~%")))
  called
  NIL

Ok, and

  CL-USER> (nth 1 '("foo" #'(lambda () (format t "called~%"))))
  #'(LAMBDA () (FORMAT T "called~%"))

But combining these,

  CL-USER> (funcall (nth 1 '("foo" #'(lambda () (format t "called~%")))))
  ; Evaluation aborted

looks like it doesn't "see" the function as a function, confirmed by

  CL-USER> (functionp (nth 1 '("foo" #'(lambda () (format t "called~%")))))
  NIL

Why? And how to fix it?


Thanks..

-- 
Jyri J. Virkki - Santa Cruz, CA

3.Mailing lists for cl-ppcre, cl-gd, cl-who, cl-interpol, and html-template

4.Need a good CL implementation for experiments

Howdy,

I'm looking for a good CL implementation to experiment with.  My main
selection criteria are:

    Reasonably complete, with good ANSI compliance

    Small size

    Easy to build, easy to modify

I'm currently looking at CLISP, and GCL.  And perhaps ABCL, though I'd
prefer to stay away from Java.

By reasonably complete I mean that it doesn't have to be perfect, or
implemented every last detail of CLOS, for example.  Just "pretty good",
and heading in that direction.

By small size, I mean small code size for the compiler / interpreter and
standard libraries.  I'm going to need to wrap my brain around it, and
the smaller and more comprehensible the codebase, the better.  That also
ties into being easy to build and modify.

I would appreciate any advice given.

Cheers,

James Graves

5.Very rusty user needs help with Allegro CL -- today, packages

I am a very rusty user (retired 15 years, haven't looked at LISP of most of that time).  Makes me a luser, I guess.

Anyway, I downloaded the Allegro trial version, and dug up some old code (written around 1990) and tried to re-compile and load
it.  I'm having problems with the package system.  Either I've forgotten more than I thought, or something has changed.  Simplest
case:  here are the first few lines of the first file in my set:

;;; -*- Mode: Lisp; Package: USER -*-



(defpackage "utilities")  ; To insure existance.

(in-package :common-lisp-user)

;;; (use-package '(:utilities)) Change for ANSI CL

(in-package :utilities)

;;;  These are from "basicmacs".

(export '(qcar qcdr qrplaca qrplacd qcaar qcadr qcdar qcddr qcaaar qcaadr qcadar
               qcaddr qcdaar qcdadr qcddar qcdddr qcaaaar qcaaadr qcaadar qcaaddr
...

I don't even get this far -- NB this did work many years ago.

I get an error that the package "UTILITIES" doesn't exist.  If I then, at the top level, call make-package, I am told that
"UTILITIES" does exist.  But the file still won't compile or load.

So, what am I doing wrong.

C. N. Alberga

PS I looked at the Allegro Lisp newgroup, but it seems to be dead or dying.

6. most basic configuration needed to run CL in emacs

7. Minimal keywords needed for constructing a full CL system

8. Scheme substitute for FUNCALL?



Return to lisp

 

Who is online

Users browsing this forum: No registered users and 84 guest