Lisp is King

Started by
325 comments, last by bishop_pass 20 years, 5 months ago
quote:Original post by Alpha_ProgDes
string fruits[] = {"apples", "oranges", "pears", "bananas"};

What did we miss here in our Lisp lessons? Unfortunately, that''s not even close. You just created an array of strings (which you can do in Lisp as well), but that''s not what the Lisp example does.

Here are the deficiencies in your C++ code:
  • It is an array, not a list composed of cons cells.
  • fruits is a different type from "apples".
  • In fact, "apples" is only a value, and not a reference in your code.
  • fuits cannot be reset to something else easily.
  • We cannot extract the spelling of the term fruits.
  • We can''t ask our program at runtime what type fruits is.
  • We haven''t coded any way of determining the number of values in the array called fruits.
  • I could go on...
_______________________________
"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.
Advertisement
quote:Original post by Fruny
int main()
{
}


As a complete program, it looks very much like a no-op to me. The symbol fruit would be discarded on exit, no side-effect

You too have missed what the Lisp program accomplishes. When the Lisp program finishes, the capability only just starts. What''s important is what you can do after the Lisp statement has been executed. In the case of your C++ program, what it accomplishes is nothing.
_______________________________
"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.
It''s pretty silly to compare C++ and Lisp - they''re completely different.

Now, I''ve just found something amazing about Lisp! You can have an integer that''s as big as you want! Like 999999999999999999999999999999999999999999! And you can multiply it and everything! This is so cool. Also it has built-in facility for complex numbers.

Firebird Entertainment
“[The clergy] believe that any portion of power confided to me, will be exerted in opposition to their schemes. And they believe rightly: for I have sworn upon the altar of God, eternal hostility against every form of tyranny over the mind of man” - Thomas Jefferson
Alpha_ProgDes - apples, oranges, pears, and bananas aren''t strings. They''re symbols, just like fruits and setf (well, setf is a special function, but you get the idea).

The closest you''d get would be


  struct cons{  void* car;  void* cdr;  const( void* car_, void* cdr_ = 0 )  : car( car_ ), cdr_( cdr )  {}};void* fruit, apples, oranges, pears, bananas;fruit = new cons( apples,                   new cons( oranges,                             new cons( pears,                                       new cons( bananas ))));  


But unfortunately, short of writing a complete Lisp interpreter, you''d be hard-pressed to reproduce a snippet of Lisp-code while preserving all the ways it can be manipulated.

[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Let's look at some of the functrionality and meta-level data which exists by examining a transcript which queries some of what can be extracted from the statement, and how we can modify the data structure as well.


(setf fruits '(apples oranges pears bananas))
(APPLES ORANGES PEARS BANANAS)
fruits
(APPLES ORANGES PEARS BANANAS)
(symbolp 'fruits)
T
(symbolp fruits)
NIL
(listp fruits)
T
(length fruits)
4
(atom 'fruits)
T
(atom fruits)
NIL
(numberp fruits)
NIL
(numberp 'fruits)
NIL
(numberp (length fruits))
T
(symbolp (car fruits))
T
(setf apples '(green-apples red-apples))
(GREEN-APPLES RED-APPLES)
(eval (car fruits))
(GREEN-APPLES RED-APPLES)
(setf fruits (cons 'peaches fruits))
(PEACHES APPLES ORANGES PEARS BANANAS)


[edited by - bishop_pass on March 9, 2003 4:56:00 PM]
_______________________________
"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.
Fruny,
Ok, I see you are aware of what''s going on under the hood and what the differences are. Your new C++ program is definitely better, but, as you pointed it out, it''s still deficient.
_______________________________
"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.
quote:Original post by bishop_pass
You too have missed what the Lisp program accomplishes. When the Lisp program finishes, the capability only just starts. What''s important is what you can do after the Lisp statement has been executed. In the case of your C++ program, what it accomplishes is nothing.


I do know what the program accomplishes, but, in all fairness, you can''t really consider that a Lisp program has completed until you have actually left the toplevel. At that point, your program won''t have accomplished anything either.

You can just go and run any [insert favourite language] within an interactive debugger; some even let you go back and modify the code on the fly. It''s definitely not as convenient, but it''s possible.

[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
quote:Original post by Tron3k Now, I''ve just found something amazing about Lisp! You can have an integer that''s as big as you want! Like 999999999999999999999999999999999999999999! And you can multiply it and everything! This is so cool. Also it has built-in facility for complex numbers.

Yeah, Lisp has some nice data types. Among them are:

  • Integers: fixnum and bignum.
  • Floating Point Numbers: short, long, single and double.
  • Ratios.
  • Complex Numbers.
  • Characters: standard- char and string-char
  • Symbols.
  • Conses.
  • Lists: Which can be arbitrary trees, functions, etc.
  • Arrays.
  • Vectors.
  • Strings.
  • Bit Vectors.
  • Hash Tables.
  • Packages.
  • Random-States.
  • Structures.
  • Functions.
_______________________________
"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.
quote:Original post by Fruny
You can just go and run any [insert favourite language] within an interactive debugger; some even let you go back and modify the code on the fly. It''s definitely not as convenient, but it''s possible.

That''s bullshit. The Lisp program could have additional code added which could operate on what was accomplished in the prior statement. You''re saying that you could do something similar with the C++ debugger. But a running C++ program cannot be programmed to take advantage of information within the debugger.
_______________________________
"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.
I''m tired of using this stupid command line lisp interpretor. What happens when the corman lisp interpretor''s 30 day trial runs out?

This topic is closed to new replies.

Advertisement