6 Sep 23:15
Binding from the stack
From: Eduardo Cavazos <wayo.cavazos@...>
Subject: Binding from the stack
Newsgroups: gmane.comp.lang.factor.general
Date: 2008-09-06 21:15:55 GMT
Subject: Binding from the stack
Newsgroups: gmane.comp.lang.factor.general
Date: 2008-09-06 21:15:55 GMT
Hello, I've been programming in Factor for a few years now. I guess I'm a slow learner because I've just now had a certain eureka moment this morning. I even think folks have mentioned this to me before but it didn't click until today. The idea I finally groked: Locals is an abstraction of the retain stack Maybe some of you are familiar with User RPL, the programming language of the HP48. Folks write some pretty complex stuff in RPL. Guess what's missing from User RPL? A retain stack. But what *do* they have? Locals. They use this syntax: -> a b << a b + >> In RPL, their "quotations" are delimited using '<<' and '>>'. The above means bind 'a' and 'b' to values from the stack and execute the program. They also support "algebraic" expressions so the above could be written as: -> a b 'a+b' Now I'm going to throw out a claim: Every piece of code which uses '>r' and 'r>' could be more clearly written using locals. I think this is an important fact because from a teachers perspective, it means you only need to show a student locals and they don't need to learn about the retain stack at all.(Continue reading)
RSS Feed