s-expressions - what are they ?
hello:
I read in a post below about s-expressions being much more powerful than a C++ class, so I googled and didn''t come up with a basic "this is a s-expression".
So what is a s-expression, technically speaking, and what does it do, practically speaking ?
:D
~V''lion
Bugle4d
~V'lionBugle4d
I found this which is pretty good basic definition: S-expression.
It seems like an s-expression is just using a list to represent code as it is done in Lisp. For example, in C++ you have func(var1, var2, var3) but in Lisp you''d do (func var1 var2 var3). The reason it is more powerful is because lisp is designed to manipulate lists (LISt Processing), so you can also manipulate code easily and use it to build new/modify old code to do whatever you need.
It seems like an s-expression is just using a list to represent code as it is done in Lisp. For example, in C++ you have func(var1, var2, var3) but in Lisp you''d do (func var1 var2 var3). The reason it is more powerful is because lisp is designed to manipulate lists (LISt Processing), so you can also manipulate code easily and use it to build new/modify old code to do whatever you need.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
So the extra power is simply lack of a clean line between code and data, allowing manipulation of both easier ?
(I''m curious- I''d like to figure lisp out)
-v''lion
(I''m curious- I''d like to figure lisp out)
-v''lion
~V'lionBugle4d
quote:I would phrase it differently(something like Lisp realizes that code is just a form of data =-), but essentialy that seems to be the main point. I'm not an expert though, and I'm still learning Lisp myself, but Lisp's power seems to come from both ease of manipulating code and 'code anytime' (ie you can create and run Lisp code at read time, compile time, run time, etc). The interactive environment also seems to be a big plus.
Original post by Vlion
So the extra power is simply lack of a clean line between code and data, allowing manipulation of both easier ?
(I'm curious- I'd like to figure lisp out)
-v'lion
[edited by - extrarius on December 8, 2003 5:36:41 PM]
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
s-expressions also provide virtually unlimited flexibility with regard to structuring data and restructuring data and redefining how data is structured at both development and runtime.
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
How ?
How is
(+ 1 2 1)
different(other than higher-level) than
int operator+(int a, int b);
Or
(a 5 4 7 32 9)
Please don't take that wrong- I do want to know.
[edited by - Vlion on December 8, 2003 12:59:17 AM]
How is
(+ 1 2 1)
different(other than higher-level) than
int operator+(int a, int b);
Or
(a 5 4 7 32 9)
//some missing brackets here.vector a;a.push_back(5);a.push_back(4);a.push_back(7);a.push_back(32);a.push_back(9);
Please don't take that wrong- I do want to know.
[edited by - Vlion on December 8, 2003 12:59:17 AM]
~V'lionBugle4d
quote:
Original post by Vlion
How ?
How is
(+ 1 2 1)
different(other than higher-level) than
int operator+(int a, int b);
Or
(a 5 4 7 32 9)//some missing brackets here.vector a;a.push_back(5);a.push_back(4);a.push_back(7);a.push_back(32);a.push_back(9);
Please don't take that wrong- I do want to know.
[edited by - Vlion on December 8, 2003 12:59:17 AM]
this simple in C++ it's only instruction
in lisp it's also a data you could manipulate, the s-expression, to reorganize the code itself by manipulate it as a range of data
the code can 'code' itself i bet if that make sense
lisp is a very intuitive language for me and looks like a little the way i have programmed before
EDIT>> i have forget to mention i'm just beginning learning lisp, with C++ in parralel (well they bought me java and others too to master until the 6 next mounth >_< doh!)
>>>>>>>>>>>>>>>
be good
be evil
but do it WELL
>>>>>>>>>>>>>>>
[edited by - Neoshaman on December 9, 2003 1:38:12 AM]
>>>>>>>>>>>>>>>be goodbe evilbut do it WELL>>>>>>>>>>>>>>>
Lisp represents code as lists, and Lisp is designed to manipulate lists. It isn''t easy for me to make an example(because I''m still learning Lisp and the only examples I can think of are rather large programs), so I''ll just talk about one: genetic programming. In C++, to do some kind of genetic programming you have to make an interpreter and complex data structures to be able to manipulate the language you invent. In Lisp, you just use its built-in ideas of code as data(in list format), and use its list processing instructions to manipulate the code and one of the built in functions to execute it and you have a basic GP already. Since everything is a first class object and Lisp supports closures, that makes it even easier because you can not only create and manipulate code but also pass it around wherever you need it just like you would a call-back in C/C++(except that in C/C++ you have to go to the trouble of making the callback function beforehand).
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement