Should I, (hypothetically); <br><br>Extend class.ss macros with a way to specify a class may be<br>- a 'collection', with matching; <br> + the data-structure to use, (List or BST)<br> + and a implementation of fold(for list, or the appropriate equivalent for BST's) (thanks Noel, very sensible advice)
<br><br>I'm comfortable with extending classes, using class.ss, but I'm unsure with extending macros, am I right in guessing that I would define a new macro that referred to the class macro.<br><br>Would it be cheating to make a class class? (class%) then use the class system to extend the class% class instead.
<br><br>thanks,<br><br>Stephen<br><br><br><br><div class="gmail_quote">On Jan 8, 2008 1:00 PM, Matthias Felleisen <<a href="mailto:matthias@ccs.neu.edu">matthias@ccs.neu.edu</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
That looks perfectly fine to me, if it is otherwise acceptable to use<br>lists for storing the collection. (If you needed random access or<br>fast search, you might consider BST's instead. In that case, you'd<br>have to write your own for-each.)
<br><br>The reason class.ss is a macro is so that people can evolve the<br>design of the class system and match it to their needs.<br><br>-- Matthias<br><div><div></div><div class="Wj3C7c"><br><br><br><br>On Jan 8, 2008, at 6:53 AM, Stephen De Gabrielle wrote:
<br><br>> Hi,<br>><br>> [Please excuse me if this is a silly question]<br>><br>> I want to 'map' or 'for-each' of a collection object which is a<br>> collection of other objects, in the same way as I would over a regular
<br>> list (also filter from the list.ss List Utilities)<br>><br>> I can just turn the collection of objects into a list of objects, but<br>> it seems there might be a better way? 'for-each-object-on-collection
<br>> object<br>><br>> ;; collection of tuples<br>> (define TupleSet% (class object%<br>> (define collection '())<br>> (super-new)<br>> ;; insert : alist -> void
<br>> (define/public (addTuple alist)<br>> (set! collection (cons (new Tuple%<br>> [initial-fields alist] ); tuple<br>> collection))
<br>> )<br>><br>><br>> ;; getTupleCount : -> number<br>> (define/public (getTupleCount)<br>> (length collection)
<br>> )<br>> ... and so on ...<br>><br>><br>> Should I just make up the smalltalk iterator equivalents as needed?<br>> eg; 'do:' from smalltalk<br>><br>> ;; do : tupleMethod -> result
<br>> (define/public (do tupleMethod)<br>> (for-each<br>> (lambda (tuple) (send tuple tupleMethod) )<br>> collection)
<br>> )<br>><br>> I'm searching for the 'right' way, or is this a silly question?<br>><br>> Cheers,<br>><br>> Stephen<br>><br>><br>><br>> --<br>> Stephen De Gabrielle
<br></div></div>> _________________________________________________<br>> For list-related administrative tasks:<br>> <a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme" target="_blank">http://list.cs.brown.edu/mailman/listinfo/plt-scheme
</a><br><br></blockquote></div><br><br clear="all"><br>-- <br>Cheers,<br><br>Stephen<br><br><br><br>--<br>Stephen De Gabrielle<br><a href="mailto:s.degabrielle@ucl.ac.uk">s.degabrielle@ucl.ac.uk</a><br>Telephone +44 (0)20 7679 5242 (x45242)
<br>Mobile 079 851 890 45<br><a href="http://www.uclic.ucl.ac.uk/annb/MaSI.html">http://www.uclic.ucl.ac.uk/annb/MaSI.html</a><br>University College London Interaction Centre<br>Remax House - 31/32 Alfred Place
<br>London - WC1E 7DP<br><br>"There's an old story about the person who wished his computer were as easy to use as his telephone. That wish has come true, since I no longer know how to use my telephone. " -- Bjarne Stroustrup
<br>