Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - m i c h a e l

#1
Anything else we might add? / Re: FOOP destructors?
March 19, 2017, 08:41:08 PM
Quote FOOP. The F should be a P.

:-)





FOOP was never meant to be a complete object-oriented system. In fact, without references in FOOP, it's not possible to write complex OO simulations. Still, it made working in newLISP (a functional programming language) more natural for someone who thinks in OO terms.



m i c h a e l
#2
Anything else we might add? / Re: Question for neglook
February 14, 2016, 11:38:17 PM
Hi hotcore!



Thank you for the kind words about the videos. They were definitely a labor of love.



I started out using Keynote and then moved on to After Effects. Keynote can do quite a bit if you use it creatively. After Effects is more difficult to start using in the beginning but is far more capable in the long run.



m i c h a e l
#3
When a method does not return a specific value, I usually return self. This was (is?) considered good practice when programming in Smalltalk. It allows you to chain method calls together. As to how inefficient it is, well, Lutz will have to be the one to address that.



m i c h a e l
#4
Hello fellow newLISPers! Long time no speakie.



At the time "FOOP" was born, it was functional because of its immutable objects. Soon, however, FOOP lost its functional nature and became what it is today (the right choice, in my opinion). That left FOOP's poor "F" without its original meaning. I jokingly offered some possible alternatives in one of my FOOP videos, but by then the name had stuck.



I'll readily admit FOOP is not object-oriented in the strict sense, but it definitely improves the experience of developing OO code in newLISP.



m i c h a e l
#5
I cannot think of a way of doing this, other than defining an accessor:
> (context (new Class 'Node))
Node
Node> (define (location lst) (if lst (setf (self 2) lst) (self 2)))
(lambda (lst)
 (if lst
  (setf (self 2) lst)
  (self 2)))
Node> (context MAIN)
MAIN
> (setq n (Node "test" '(5 3)))
(Node "test" (5 3))
> (:location n)
(5 3)
> (:location n '(14 3))
(14 3)
> n
(Node "test" (14 3))
> _


If you do want to set and get without writing an accessor, you could do the following to make the intention more clear:
> (context (new Class 'Node))
Node
Node> (constant 'name 1 'location 2)
2
Node> (context MAIN)
MAIN
> (setq n (Node "test" '(5 3)))
(Node "test" (5 3))
> (n Node:location)
'(5 3)
> (setf (n Node:location) '(14 3))
(14 3)
> n
(Node "test" (14 3))
> _


Personally, I prefer the former solution.



m i c h a e l
#6
Whither newLISP? / Re: Object Philosophy...
January 21, 2013, 02:58:04 AM
The way I do this is to define class constants:
> (context (new Class 'Point))
Point
Point> (constant 'x 1 'y 2)
2
Point> (define (move new-x new-y) (setf (self x) new-x (self y) new-y) (self))
(lambda (new-x new-y) (setf (self x) new-x (self y) new-y) (self))
Point> (context MAIN)
MAIN
> _


Within the context we can use (self x) and (self y) to refer to the attributes. Outside the class we use the fully qualified name:


> (setq p1 (Point 0 0))
(Point 0 0)
> (:move p1 10 20)
(Point 10 20)
> (p1 Point:x)
10
> (p1 Point:y)
20
> _


m i c h a e l
#7
I'd like to second Jo's thanks to Lutz and cormullion. Lutz for developing this beautyful language that finally ended my search for the perfect one. And cormullion for always being ready to lend a helpful and friendly hand here at the club.



Here's to another year of Lutz, cormullion, and newLISP!



m i c h a e l
#8
newLISP in the real world / Re: formatting 'nil'
December 03, 2012, 09:53:41 AM
cormullion,



Yes, I'm still here, lurking in the shadows. I don't do much programming lately, but I'm still an enthusiastic newlisper!
#9
newLISP in the real world / Re: formatting 'nil'
December 03, 2012, 09:38:45 AM
cormullion's solution is considerably faster:


> (time (replace nil fruits "") 1000000)
173.114
> (time (map (fn (x) (or x "")) fruits) 1000000)
3435.875
> _
>


m i c h a e l
#10
newLISP in the real world / Re: regex help
April 20, 2012, 12:03:03 AM
Hi joejoe!



Will this work for you?


find-all {<item>(.+?)</item>}


Hope this helps.



m i c h a e l
#11
Quote from: "conan"... shouldn't class declaration go inside each class defining file?


You should put it into its own file if the class definition is large enough or if you will be using the class in multiple projects. Short class definitions or project specific classes don't need to go into separate files.


Quote from: "cormullion"michael - hello again! How are you‽


Hi cormullion! I'm doing great, thanks for asking. Melissa and I started a freelance business after her position was cut at the university, and it has been nonstop ever since. I haven't been doing any programming lately, but I do check this forum every day. How have you been?



m i c h a e l
#12
I completely forgot about not needing to define a parameter for the object! I said I was rusty ;-)



conan, this means wherever we had a parameter for the object we would remove that  and use self instead:


; definitions

(define (Time:Time (t (date-value)) (zone 0))
   (list Time t zone))

(define (Time:show)
   (date (self 1) (self 2)))

(define (Time:days-between other)
   "Return difference in days between two times."
   (div (abs (- (self 1) (other 1))) (* 24 60 60)))

(define (Time:get-hours)
   "Return hours."
   (int (date (self 1) (self 2) {%H})))

(define (Time:get-day)
   "Return day of week."
   (date (self 1) (self 2) {%A}))

(define (Time:leap-year?)
   (let ((year (int (date (self 1) (self 2) {%Y}))))
      (and (= 0 (% year 4))
         (or (!= 0 (% year 100)) (= 0 (% year 400))))))


m i c h a e l
#13
Hi conan!



I'm a little rusty at this, but I ran the code through the debug function and found that t is nil within Time:show (hence the error message). Why? I have no idea! Lutz?



m i c h a e l
#14
Whither newLISP? / Re: Why do you use sym?
July 04, 2011, 05:54:50 PM
Quote from: "Kazimir"Do you have some other example of use of sym?


I mostly use it for expression-building in my language and FOOP experiments, but even then, not very often. So, no, not really :-)



m i c h a e l
#15
newLISP and the O.S. / Re: Colors in Terminal
May 29, 2011, 09:50:17 AM
This works using Terminal on OS X:


(println "27[0;31mHello world!27[0m")


Hope this helps.



m i c h a e l