Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Constructing functions at runtime
Hi all,

in combination with LISP I found quite a few times comments like "LISP
is good for AI, as functions can be built up at dynamically because the
program itself is a list".

However, I'm not sure about such statements; AFAIK, these would either
require the use of (eval ...) or (non-hygienic) macros in Scheme, would
they not?  And I think those two are seen as bad practice, right?

So what do you think about such statements, are they true for Scheme,
didn't I get the point, are they "outdated" or simply nonesense?  Or are
there any other reasons why LISP/Scheme is exceptionally well suited for AI?

Thanks,
Daniel

--
Done:     Bar-Sam-Val-Wiz, Dwa-Elf-Hum-Orc, Cha-Law, Fem-Mal
Underway: Ran-Gno-Neu-Fem
To go:    Arc-Cav-Hea-Kni-Mon-Pri-Rog-Tou

Report this thread to moderator Post Follow-up to this message
Old Post
Daniel Kraft
03-01-08 12:21 AM


Re: Constructing functions at runtime
Daniel Kraft <d@domob.eu> writes:

> Hi all,
>
> in combination with LISP I found quite a few times comments like "LISP
> is good for AI, as functions can be built up at dynamically because
> the program itself is a list".
>
> However, I'm not sure about such statements; AFAIK, these would either
> require the use of (eval ...) or (non-hygienic) macros in Scheme,
> would they not?  And I think those two are seen as bad practice,
> right?

I think the author is referring to macros --- code that writes
transforms code, often referred to as a "program that writes a program."

> So what do you think about such statements, are they true for Scheme,
> didn't I get the point, are they "outdated" or simply nonesense?  Or
> are there any other reasons why LISP/Scheme is exceptionally well
> suited for AI?

One reason for the persistence of this idea is that Lisp was originally
developed by John McCarthy and used in AI Research, connected with the
misconception that Lisp is used for nothing else.  (a) You'd be surprised to
know some of the things that Lisp is used for, (b) Paul Graham says that
Lisp turns itself into a programming language that's good for whatever
you want it to do, and (c) companies and projects that do use Lisp do
not widely publicize it in certain cases.

I'm using Scheme to write a population simulation program that will
simulate stochastic and time-dependent population parameters; every day
I feel like Graham's statement is coming true more and more.
Simulations are usually written in C, Mathematica or Matlab, or more
recently Python.

Joel

--
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA  02114
(617) 643-1432
(303) 880-3109

Report this thread to moderator Post Follow-up to this message
Old Post
Joel J. Adamson
03-01-08 12:21 AM


Re: Constructing functions at runtime
>> However, I'm not sure about such statements; AFAIK, these would either 
>
> I think the author is referring to macros --- code that writes
> transforms code, often referred to as a "program that writes a program."

Ah, might be (while my first understanding was more towards the eval-idea).
 
>
> One reason for the persistence of this idea is that Lisp was originally
> developed by John McCarthy and used in AI Research, connected with the
> misconception that Lisp is used for nothing else.  (a) You'd be surprised 
to
> know some of the things that Lisp is used for, (b) Paul Graham says that
> Lisp turns itself into a programming language that's good for whatever
> you want it to do, and (c) companies and projects that do use Lisp do
> not widely publicize it in certain cases.
>
> I'm using Scheme to write a population simulation program that will
> simulate stochastic and time-dependent population parameters; every day
> I feel like Graham's statement is coming true more and more.
> Simulations are usually written in C, Mathematica or Matlab, or more
> recently Python.

Well, yes, I used Scheme mainly for small "toy" programs so far
(otherwise mostly C++), but I really like the language, both because of
the general design and because functional programming is refreshingly
different from what I did before.

Daniel

--
Done:     Bar-Sam-Val-Wiz, Dwa-Elf-Hum-Orc, Cha-Law, Fem-Mal
Underway: Ran-Gno-Neu-Fem
To go:    Arc-Cav-Hea-Kni-Mon-Pri-Rog-Tou

Report this thread to moderator Post Follow-up to this message
Old Post
Daniel Kraft
03-01-08 12:21 AM


Re: Constructing functions at runtime
Daniel Kraft wrote:
> in combination with LISP I found quite a few times comments like "LISP
> is good for AI, as functions can be built up at dynamically because the
> program itself is a list".

It would be more accurate to say "Scheme is good
for AI, as procedures can be created dynamically
because lambda expressions evaluate to procedures,
not to lists."

The comments that identify lists with functions
are a legacy of dynamic scoping, which created the
funarg problems that plagued most dialects of Lisp
until the debut of Scheme in 1975.

That is not to say there is no role for eval, or
for the representation of eval'ed expressions as
lists, but modern higher-order languages create
procedures dynamically without using lists or eval.

Some people's preference for lists and symbols over
pattern languages and identifiers in macro systems
may be related to the historical glorification of
lists and eval for their role in simulating dynamic
creation of procedures in dynamically scoped Lisps,
but any such relationship would represent nothing
more than the usual popularity of sloppy thinking.

Will

Report this thread to moderator Post Follow-up to this message
Old Post
William D Clinger
03-01-08 12:21 AM


Re: Constructing functions at runtime
This thread broaches on your thoughts about how folks generate code in
Scheme:

http://groups.google.com/group/plt-...48149e9330e5809

Report this thread to moderator Post Follow-up to this message
Old Post
Griff
03-01-08 12:21 AM


Re: Constructing functions at runtime
William D Clinger <cesura17@yahoo.com> writes:

> Daniel Kraft wrote: 

[...]

> Some people's preference for lists and symbols over
> pattern languages and identifiers in macro systems
> may be related to the historical glorification of
> lists and eval for their role in simulating dynamic
> creation of procedures in dynamically scoped Lisps,
> but any such relationship would represent nothing
> more than the usual popularity of sloppy thinking.

So, do macro definitions return lists? (those lists being lisp forms)

Joel

--
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA  02114
(617) 643-1432
(303) 880-3109

Report this thread to moderator Post Follow-up to this message
Old Post
Joel J. Adamson
03-01-08 12:21 AM


Re: Constructing functions at runtime
Joel J Adamson asked:
> So, do macro definitions return lists? (those lists being lisp forms)

In portable RnRS code (where n is one of 2, 3, 4, 5, or 6),
whether macro definitions return lists is not observable.

The argument to eval is usually a list, but that list
is then run through a macro expander and the result of
that expansion is executed without giving user code any
opportunity to examine that intermediate result.

Will

Report this thread to moderator Post Follow-up to this message
Old Post
William D Clinger
03-01-08 12:21 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Scheme archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:19 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.