[chuck-users] Are array types really classes ?

Kassen signal.automatique at gmail.com
Thu Sep 3 16:17:04 EDT 2009


Cyrille;

Very simple things like (algebraic) vectors, list of probabilities, etc. Of
> course I can always make classes that contain just a vector and duplicate
> every needed member functions and operators of float[], but that feels a
> bit
> silly .
>
>
Wouldn't writing a Vector class, then creating a array of those come down to
this?

Vector my-vectors[8];

Would do the trick, assuming you wrote the "Vector" class. That will get you
everything that float[] has, I think, at least everything that "float[]" has
that "float" lacks.


> Moreover, unless there is some way of writing an implicit reference cast
> operator from foo to float[] (again, excuse this possibly trivial question,
> I
> am learning), I won't be able to use existing functions that take array
> references as parameters directly on foo (I will have to pass the member
> foo.content or trivially overload all of them).
>

We don't have operator overloading right now. At least you can't overload
them yourself; of course the ChucK operator is quite overloaded. I'd still
like to have overloading of the ChucK operator for classes we write
ourselves (probably cast as well). Right now they can't be chucked to other
objects to yield values or form connections, etc. This seems a bit unnatural
to me; basically everything but the stuff we create can be chucked to things
while -hopefully- the things we just created are very important to the
domain we are reasoning about.



> Yes I am lazy :)
>
>
A comendable property for a programmer, I hear :-).

Good questions.

Yours,
Kas.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20090903/2245294c/attachment.html>


More information about the chuck-users mailing list