[chuck-users] shreds, namespace, functions, classes, etc

Kassen signal.automatique at gmail.com
Thu Nov 15 11:46:54 EST 2007


Dear list,

Shreds are objects (of type Shred) and functions aren't objects. This is all
good and well but it gets harder when we spork a function and the function
becomes a Shred and hence a Object. Consider this;

------------------------
fun void tester()
    {
    "boom" => string beep;
    while(1)
        {
        <<<beep>>>;
        second => now;
        }
    }


spork ~ tester() @=> Shred foo;
5::second => now;

"clik" => foo.beep; //this doesn't work

day=> now;
----------------------------------------

It's not so clear to me *why* the offending line doesn't work. Maybe I'm
misunderstanding something or making a syntax error but I think that what we
are seeing here is a loss of namespace that would be useful and I don't
understand why this happens.

I also tried stuff along these lines;

----------------------
class Bar extends Shred
    {
    //stuff including variables and a constructor
    }
------------------------------

If I do that I can instantiate a "Bar" but all it does is run it's
constructor; I can't manage to spork a Bar or assign a sporked shred to a
Bar. I can also make a array of Bar's but all that gets me is the
constructor running;

---------------------------
class Bar extends Shred
    {
    static int number;
    <<<number++>>>;
    }

//print a series of numbers, no shreds in sight
 Bar array[5];
----------------------------------

So, now I'm quite happy I said so many times that there are no "stupid n00b
questions" because now it's my turn to ask exactly what a "Shred" is because
I'm starting to feel like I have no idea. :¬)

Could somebody please explain to me exactly what's going on here?


Yours,
Kas.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20071115/cfeeb08a/attachment.htm 


More information about the chuck-users mailing list