[chuck-users] object / class hacking

Hans Aberg haberg at math.su.se
Wed Sep 30 16:11:19 EDT 2009

On 30 Sep 2009, at 21:30, Andrew C. Smith wrote:

>> A check check in the source codes suggested chuck is using std::map  
>> for the
>> associative array part. Then it is just to export to the chuck  
>> language
>> iterator type and functions begin(), end().
> Right, but as I understand it Robert wanted to use an array of
> Objects.

I was going he would clarify.

> It seems that the associative array only works to associate
> strings with values, so (for example) you couldn't do:
> int foo[0];
> 1 => foo[Bar bar];
> because the associations can't take an Object. You'd be left with
> creating a symbolic string for every created Object, rather than
> having an array of Objects that you could search through. Iterating
> over the array seems so fast (especially if they're sortable) that
> throwing a bunch of strings into the mix would be tough. Side thought:
> class ObjectString {
> Object foo;
> string bar;
> ...(set, get, whatever)...
> }

Yes, that is what though to. Otherwise, one would have to require  
objects to have equality comparisons for hash maps, and inequalities  
(total order) for maps (balanced trees).

It might be called:

class ObjectKey {
   Object object_;
   string key_;

> Andrew (thanks, Hans, for catching how I only sent this to you)

This mailing list server sets a reply-to field, which can play tricks  
on you, as there is no standard on how it should behave, I think. So  
different mail programs may handle it differently.


More information about the chuck-users mailing list