Hello, I saw that the stack effect of every slot reader slot>> is ( object -- value ). Thus the object is popped off the stack. If I want to get the value of another slot, I do not have the object to query it. So I have to dup it first.
How can I do this the idiomatic way ? Suppose that I have a rectangle class defined as (code kept to a bare minimum for the sake of clarity): TUPLE: rectangle { width float } { height float } ; Now I define a method to calculate the area of a rectangle. Note the use of dup and swap to access both slots. I feel that there should be a better way to access them. M: rectangle area dup width>> swap height>> * ; I can use it like this: <rectangle> 100 >>width 50 >>height area . I thought of doing like this: SYMBOL: temp M: rectangle area temp [ temp get width>> temp get height>> * ] with-variable ; But now I have an implementation detail (the fact that temp is a symbol) that is leaking out of the method body. It doesn't feel right. I should be able to avoid SYMBOL and use "\ temp" but Factor curiously complains: "Word not found in current vocabulary search path". The \ parsing word should avoid trying to execute the word. Any idea are welcome. Thank in advance, Ludovic Kuty ------------------------------------------------------------------------------ Check out the new SourceForge.net Marketplace. It is the best place to buy or sell services for just about anything Open Source. http://p.sf.net/sfu/Xq1LFB _______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk