Dylan Tip #101: don't use keyword init-values with class allocated slots 
Author Message
 Dylan Tip #101: don't use keyword init-values with class allocated slots

Hi,

Since it is on topic, I thought I'd share a tip from a Dylan compiler hacker
who found an inefficiency in my code. Harlequin Dylan's keyword init values
work and they become rather {*filter*}ive after a while. However, I was using them
with a class allocated slot (actually each-subclass):

        define class <foo> (<object>)
          each-subclass slot quux = 0, init-keyword: quux:;
        end class;

        define class <bar> (<foo>)
          keyword quux: = 1;
        end class;

This means (in Harlequin Dylan) that the class allocated slot gets
reinitialized as each instance is made. This is obviously unnecessary as the
slot has the same value across the class.

Better would have been:

        define class <foo> (<object>)
          each-subclass slot quux = 0, init-keyword: quux:;
        end class;

        define class <bar> (<foo>)
          inherited each-subclass slot quux = 1;
        end class;

__Jason



Sun, 10 Mar 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Back door to 'slot-value-using-class?

2. 101 Uses of a 'C++' Text

3. 101 Uses of a 'C++' Text

4. So how does a keyword init value work?

5. TIP #101: Export Tcltest Configuration

6. Need help with Class-Allocated Slots

7. __init__ keyword param for sub-class?

8. Fun with class allocated slots

9. Structure slot-init accessing previous slot

10. CLASS 101

11. :ALLOCATION :CLASS: getting slot value

12. init-once class 'static' data

 

 
Powered by phpBB® Forum Software