From: Coby
Subject: retrieving a lost defun
Date: 
Message-ID: <7tjdr5$j9o$1@nnrp1.deja.com>
I have lost the source for a function definition (ie "Are you sure you
want to delete this"  Duh, i dunno, whatever...)  It is currently in
Allegro's memory, evaluated and usable but not saved in a file.

Is there a way in Allegro 5 to print out the definition and save me
from re-writing it?

(hoping, hoping, hoping.....)

Coby

(Artificial Intelligence - for those who don't have the real kind...)


Sent via Deja.com http://www.deja.com/
Before you buy.

From: Christopher R. Barry
Subject: Re: retrieving a lost defun
Date: 
Message-ID: <871zb6kza2.fsf@2xtreme.net>
Coby <····@my-deja.com> writes:

> I have lost the source for a function definition (ie "Are you sure you
> want to delete this"  Duh, i dunno, whatever...)  It is currently in
> Allegro's memory, evaluated and usable but not saved in a file.
> 
> Is there a way in Allegro 5 to print out the definition and save me
> from re-writing it?

If it is interpreted then you have hope. Do:

  :step my-function

and you'll be able to see the source as you step through it. If you
compiled it then the best you can do is probably (DISASSEMBLE
'MY-FUNCTION), which won't be very helpful. (Calling DISASSEMLE on an
interpreted function will compile it by the way....)

This is a good lesson for you in a way, kinda like accidentally doing
rm -rf * when your current directory is ~/ instead of ~/.netscape/
will really teach you good to not make such a mistake again....

Christopher
From: Marc Battyani
Subject: Re: retrieving a lost defun
Date: 
Message-ID: <6480E55015DC70F2.F8008EB620BCC04F.C3DF85F408D21FCE@lp.airnews.net>
Coby <····@my-deja.com> wrote in message ·················@nnrp1.deja.com...
> I have lost the source for a function definition (ie "Are you sure you
> want to delete this"  Duh, i dunno, whatever...)  It is currently in
> Allegro's memory, evaluated and usable but not saved in a file.
>
> Is there a way in Allegro 5 to print out the definition and save me
> from re-writing it?

Try describe (I dont know if it works in ACL):

CL-USER 16 > (defun foo (a b)
              (+ a b))
foo

CL-USER 17 > (describe #'foo)

#'(lambda (a b) (declare (lambda-name foo)) (block foo (+ a b))) is a
type::interpreted-function
code      (lambda (a b) (declare (lambda-name foo)) (block foo (+ a b)))

Marc Battyani
From: Duane Rettig
Subject: Re: retrieving a lost defun
Date: 
Message-ID: <47lkx99pm.fsf@beta.franz.com>
"Marc Battyani" <·············@csi.com> writes:

> Coby <····@my-deja.com> wrote in message ·················@nnrp1.deja.com...
> > I have lost the source for a function definition (ie "Are you sure you
> > want to delete this"  Duh, i dunno, whatever...)  It is currently in
> > Allegro's memory, evaluated and usable but not saved in a file.
> >
> > Is there a way in Allegro 5 to print out the definition and save me
> > from re-writing it?
> 
> Try describe (I dont know if it works in ACL):
> 
> CL-USER 16 > (defun foo (a b)
>               (+ a b))
> foo
> 
> CL-USER 17 > (describe #'foo)
> 
> #'(lambda (a b) (declare (lambda-name foo)) (block foo (+ a b))) is a
> type::interpreted-function
> code      (lambda (a b) (declare (lambda-name foo)) (block foo (+ a b)))

No, describe doesn't give you the source code in Allegro CL:

USER(1): (defun foo (a b) (+ a b))
FOO
USER(2): (describe #'foo)
#<Interpreted Function FOO> is a FUNCTION.
  The arguments are (A B)
USER(3): 

Instead, use the CL function that it specifically defined for that
purpose: function-lambda-expression:

USER(3): (function-lambda-expression #'foo)
(LAMBDA (A B) (BLOCK FOO (+ A B)))
NIL
FOO
USER(4): 

Whether this behavior is saved or not when the function is compiled
depends on how the user has it set up; see the documentation on the
variable excl:*save-function-lambda-expression*, and also the
function excl:uncompile.

USER(4): (compile 'foo)
FOO
NIL
NIL
USER(5): (function-lambda-expression #'foo)
NIL
NIL
FOO
USER(6): (defun foo (a b) (+ a b))
FOO
USER(7): (setq excl::*save-function-lambda-expression* t)
T
USER(8): (compile 'foo)
FOO
NIL
NIL
USER(9): (function-lambda-expression #'foo)
(LAMBDA (A B) (BLOCK FOO (+ A B)))
NIL
FOO
USER(10): 

-- 
Duane Rettig          Franz Inc.            http://www.franz.com/ (www)
1995 University Ave Suite 275  Berkeley, CA 94704
Phone: (510) 548-3600; FAX: (510) 548-8253   ·····@Franz.COM (internet)
From: Coby
Subject: Re: retrieving a lost defun
Date: 
Message-ID: <7tlbja$u4f$1@nnrp1.deja.com>
In article <·············@beta.franz.com>,
  Duane Rettig <·····@franz.com> wrote:
> "Marc Battyani" <·············@csi.com> writes:
>
> > Coby <····@my-deja.com> wrote in message news:7tjdr5
······@nnrp1.deja.com...
> > > I have lost the source for a function definition (ie "Are you
sure you
> > > want to delete this"  Duh, i dunno, whatever...)  It is currently
in
> > > Allegro's memory, evaluated and usable but not saved in a file.
> > >
> > > Is there a way in Allegro 5 to print out the definition and save
me
> > > from re-writing it?
> >

> Instead, use the CL function that it specifically defined for that
> purpose: function-lambda-expression:
>
> USER(3): (function-lambda-expression #'foo)
> (LAMBDA (A B) (BLOCK FOO (+ A B)))
> NIL
> FOO
> USER(4):
>
> Whether this behavior is saved or not when the function is compiled
> depends on how the user has it set up; see the documentation on the
> variable excl:*save-function-lambda-expression*, and also the
> function excl:uncompile.

> Duane Rettig          Franz Inc.            http://www.franz.com/

Thanks for the feed back!  excl:*save-function-lambda-expression* is
nil, unfortunately, and :uncompile won't.

step produced the following useful result!
-> :step 'get-gov-max-end-date
 1: 'GET-GOV-MAX-END-DATE => GET-GOV-MAX-END-DATE

->

However, the happy ending is:  i had cut and pasted it into another
file...had it all along  *blush*

Now the question is does that mean i'm smarter than it may have seemed,
or even dumber  :-)

Coby
(i will, however, remember 'function-lambda-expression - and the whole
point is to keep learning, right?)


Sent via Deja.com http://www.deja.com/
Before you buy.
From: Jim Bushnell
Subject: Re: retrieving a lost defun
Date: 
Message-ID: <7tltu9$avo$1@sloth.swcp.com>
In my copy of ACL 5.0.1, I also found it possible to inspect, and follow on
to the code definition, at least for an intrepreted function
Coby <····@my-deja.com> wrote in message ·················@nnrp1.deja.com...
> In article <·············@beta.franz.com>,
>   Duane Rettig <·····@franz.com> wrote:
> > "Marc Battyani" <·············@csi.com> writes:
> >
> > > Coby <····@my-deja.com> wrote in message news:7tjdr5
> ······@nnrp1.deja.com...
> > > > I have lost the source for a function definition (ie "Are you
> sure you
> > > > want to delete this"  Duh, i dunno, whatever...)  It is currently
> in
> > > > Allegro's memory, evaluated and usable but not saved in a file.
> > > >
> > > > Is there a way in Allegro 5 to print out the definition and save
> me
> > > > from re-writing it?
> > >
>
> > Instead, use the CL function that it specifically defined for that
> > purpose: function-lambda-expression:
> >
> > USER(3): (function-lambda-expression #'foo)
> > (LAMBDA (A B) (BLOCK FOO (+ A B)))
> > NIL
> > FOO
> > USER(4):
> >
> > Whether this behavior is saved or not when the function is compiled
> > depends on how the user has it set up; see the documentation on the
> > variable excl:*save-function-lambda-expression*, and also the
> > function excl:uncompile.
>
> > Duane Rettig          Franz Inc.            http://www.franz.com/
>
> Thanks for the feed back!  excl:*save-function-lambda-expression* is
> nil, unfortunately, and :uncompile won't.
>
> step produced the following useful result!
> -> :step 'get-gov-max-end-date
>  1: 'GET-GOV-MAX-END-DATE => GET-GOV-MAX-END-DATE
>
> ->
>
> However, the happy ending is:  i had cut and pasted it into another
> file...had it all along  *blush*
>
> Now the question is does that mean i'm smarter than it may have seemed,
> or even dumber  :-)
>
> Coby
> (i will, however, remember 'function-lambda-expression - and the whole
> point is to keep learning, right?)
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
From: Duane Rettig
Subject: Re: retrieving a lost defun
Date: 
Message-ID: <47lkxcrx7.fsf@beta.franz.com>
"Jim Bushnell" <········@swcp.com> writes:

> In my copy of ACL 5.0.1, I also found it possible to inspect, and follow on
> to the code definition, at least for an intrepreted function

This is true, and in fact there is another place to look if
you have sent the interpreted function to compile with
excl:*save-function-lambda-expression* turned on.  But these
locations depend on internal structures in the implementation,
which may change in future versions, and since there is an external
interface (i.e. the CL function function-lambda-expression), it is
preferable to use that.  Note that functions that are loaded already-
compiled from .fasl files never have source code included.

-- 
Duane Rettig          Franz Inc.            http://www.franz.com/ (www)
1995 University Ave Suite 275  Berkeley, CA 94704
Phone: (510) 548-3600; FAX: (510) 548-8253   ·····@Franz.COM (internet)