Arc Forumnew | comments | leaders | submitlogin
1 point by Pauan 4930 days ago | link | parent

No no no. I mean, yes, your way will work, but you can just use letr. No need to use set-attribute:

  (letr self (object print (fn () (+ "#<table of length " len.self ">")))
    self)
You can use set-attribute if you want to, but there's no need, since letr behaves like Scheme's letrec.

And soon I'll try changing it so you don't even need the letr:

  (object print (fn () (+ "#<table of length " len.self ">")))


2 points by rocketnia 4930 days ago | link

Ohh, okay! Sorry, for some reason I thought 'letr was another name for 'ret or something. For some reason 'letrec didn't cross my mind. XD

In this kind of situation I use a utility I call 'named:

  (named foo bar)
  -->
  (ret foo nil (= foo bar))

-----