Introducing Objective newLISP

Started by itistoday, December 08, 2009, 04:20:24 PM

Previous topic - Next topic

hilti

#15
Quote from: "m i c h a e l"

(new Class 'Book)
(new Class 'Chapter)
(new Class 'Paragraph)

(define (Paragraph:text) (self 1))
(define (Chapter:text)
(format
"Chapter %dn%sn"
(self 1) (join (map (curry :text) (2 (self))) "n")
)
)
(define (Book:text)
(format
"%snn%snThe Endn"
(self 1) (join (map (curry :text) (2 (self))) "n")
)
)

(setq frankenstein
(Book "Frankenstein"
(Chapter 1
(Paragraph "I am by birth a Genevese; and my family is . . .")
(Paragraph "As the circumstances of his marriage illustrate . . .")
(Paragraph "Beaufort had taken effectual measures to conceal . . .")
)
(Chapter 2
(Paragraph "We were brought up together; there was not quite . . .")
(Paragraph "On the birth of a second son, my junior by . . .")
(Paragraph "No human being could have passed a happier . . .")
)
(Chapter 3
(Paragraph "When I had attained the age of seventeen, my . . .")
(Paragraph "Elizabeth had caught the scarlet fever; her . . .")
(Paragraph "She died calmly; and her countenance expressed . . .")
)
)
)

(println (:text frankenstein))


Hi m i c h a e l!



I'm just learning FOOP in newLISP from example code. The hardest part is to find some written in newLISP ;-)

Your "Book example" is great but I get this error:



ERR: invalid function in function format : (MAIN:self 1)
called from user defined function Book:text


May You help me?



Thanks!

Marc
--()o Dragonfly web framework for newLISP

http://dragonfly.apptruck.de\">http://dragonfly.apptruck.de

itistoday

#16
Quote from: "hilti"
ERR: invalid function in function format : (MAIN:self 1)
called from user defined function Book:text


It works fine on my end, I'm guessing you're running an older version of newLISP that doesn't support the new FOOP stuff.
Get your Objective newLISP groove on.

cormullion

#17
Quote from: "itistoday"ObjNL is for situations where you have complicated object relationships, and objects are being passed around and modified.


Ah, yes. I'm very grateful for the advice. I think I'm more interested in modelling the hierarchical structure rather than the interactions of objects, so you're probably right...! I shall get round to ObjNL soon.

m i c h a e l

#18
Hi Mark!


Quote from: "hilti"I'm just learning FOOP in newLISP from example code.

The hardest part is to find some written in newLISP ;-)


:-) I'm nearing completion of a new video on FOOP, but it's just a basic overview. The next video I'd like to do should contain a more complex example, so I'm hoping that one will clear up any grey areas. Although, to be honest, there's a lot about FOOP I still don't understand myself ;-)


Quote from: "hilti"Your "Book example" is great but I get this error:



Code:

ERR: invalid function in function format : (MAIN:self 1)

called from user defined function Book:text





May You help me?


I'd be happy to, but I think Greg already nailed it. newLISP gained the self function in v.10.1.8 and had a bug fix in v.10.1.9. self is still only available through a development release.



m i c h a e l