Set question

Started by newdep, November 27, 2007, 01:11:49 PM

Previous topic - Next topic

newdep

Lutz, this may sound like a very very very very stupid question ..



>(set 'here '(there where ))

(there where)



Are there and where now evaluated and set to nil inside newlisp

and known as symbols?  



PS: assuming you just started the newlisp console



Norman,
-- (define? (Cornflakes))

Lutz

#1
yes, they exist now as symbols in the MAIN namespace and contain 'nil'. But they have not been evaluated, because they are inside a quoted list.



They get put into the symbol table when parsing the source: "(set 'here '(there where ))".



After parsing the source and translating it into an internal s-expression format, the expression gets evaluated, assigning the list '(there where ) to the symbol 'here.



Lutz

newdep

#2
..oke thank you for the clear answer...



Has this always been the fact? because im now wondering why I got

away with some list content in my programs while not using contexts or OOP.



I was always under the impression that anything inside an explicit list

was static until evaluated with .i.e. 'eval..until then the data inside a list

was abstract and unknown to the main-context when using 'set. I mean

only for lists!





PS: like this, i still think its odd.. ->



newLISP v.9.2.7 on Linux, execute 'newlisp -h' for more info.



> (set 'X '(i am a new list))

(i am a new list)

> (set 'i:am "a new list")



context expected in function set : i

>







Norman.
-- (define? (Cornflakes))

Lutz

#3
yes, it has always been this way. After the first statement 'i' exists as a  normal symbol variable containing 'nil'. In the next statement then 'i' is expected to be either a context or contain a context. Only the the 'context' function can promote a normal variable to a context symbol:


newLISP v.9.2.0 on OSX, execute 'newlisp -h' for more info.

> (set 'X '(i am a new list))
(i am a new list)
> (set 'i:am "a new list")

context expected in function set : i
> (context 'i "am" "a new list")
"a new list"
> i:am
"a new list"
>


Lutz

newdep

#4
Its not that i dont understand the process, but its more the logical way behind it..



Perhpas I should not try and program two different languages within 1 week,

that creates a logical-misunderstanding of assumptions ;-)



The newlisp bell rings again ;-)



PS: I must say that the context extention newlisp got in 9.2.7 is a very nice growth in power...We should have more of these brain-storms here on the forum ;-)
-- (define? (Cornflakes))

Cyril

#5
Quote from: "newdep"Perhpas I should not try and program two different languages within 1 week, that creates a logical-misunderstanding of assumptions ;-)


Wrong! Programming two different languages within one week is the only way to note you misunderstandings and then clear them up. If you program one language now and forever, you a doomed to stay with you misunderstandings for the rest of you live. In fact to be a second point of view is the main purpose for Lisp, aside its practical usefulness. ;-)
With newLISP you can grow your lists from the right side!

newdep

#6
In my 20 years of programming:



I had the most fun with Assembler..

Found Basic too simple..

I had the most problems controlling Pascal..

Did C every now and then, but never found it exciting..

I had lots of fun with Tcl/Tk..love it..

Never understood C++..

Icon and Prolog where nice too snif at..

I Hated Perl back in 1994..and still do..

Had the most refreshing mind blow with Rebol in 1999..

Found the best mixture in newLisp and Rebol for my mind..





So evaluating the above. I should have learned Scheme back in 1986 ;-)
-- (define? (Cornflakes))

Cyril

#7
Quote from: "newdep"Im my 20 years of programming:

(...)

So evaluating the above. I should have learned Scheme back in 1986 ;-)


Very similar, with some minor differences:

- In 1994 I have loved Perl, begun to hate it circa 1997. My first CGI scripts (when the word CGI was new and shining)  was all-perl. Sweet memories of libwww_perl by Roy Fielding...

- Newer understood tcl/tk. It seems plain silly to me.

- Not understanding Rebol now. The idea of "simple everyday tasks should be simple" is brilliant (it's why we all love newlisp ;-), but the Rebol implementation of it is awful.



By the way, do yo see http://factorcode.org">factor? Seems promising for me.



And, just for fun, http://slobin.livejournal.com/129916.html">here is my own "hello, world" -- the very first program I have really run on a real hardware, not just wrote at the piece of paper. Do not be discouraged by Cyrillic, just look at the picture! As you can see, I have loved recursion in 1982 already. ;-)
With newLISP you can grow your lists from the right side!

cormullion

#8
I like the look of factor, and the community is active. If I hadn't used up most of my brain's capacity trying to learn newLISP, I'd be looking at factor...