[chuck-users] Public sporking?

lucas samaruga samarugalucas at gmail.com
Sun Jun 8 17:27:22 EDT 2008


Hi

I think these are problems for the Chuck compiler, there are things that I
think that makes no sense.
Perhaps what I like to me is a compiler that will not allow me to do
mistakes

 // printf: print float :_)
public float printf( float n ) {
    <<< n >>>;
    //return void;
}

printf( float n ) => float num;
<<< num >>>;

Uncomment the line return void, there is a wrong message syntax.

Greetings
Lucas


2008/6/7, Kassen <signal.automatique at gmail.com>:
>
>
> Hi Kas,
>>
>
> Hey, Peter,
>
>
>>
>> I don't see what the problem is.
>
>
> There is no real problem, there is just some strange behaviour and a lack
> of documentation. The word "public" as far as I know isn't defined at all
> aside from how it affects classes. I'm really quite sure it's not defined
> for functions in ChucK.
>
>
>> You're not sporking 'a public'; surely public is an access modifier that
>> can apply to functions perfectly viably.
>
>
> Well, clearly it's a function but I defined it by calling it a "public".
>
> if
>
> fun void foo() {}
>
> is a "function"
>
> then by my logic
>
> public void bar() { }
>
> is a "public". I suppose this is pushing some linguistic envelopes but you
> have to admit there is some logic to it, right? ;¬)
>
>
>
>> I wouldn't expect the code you posted to be illegal, although there may be
>> some slight redundancy.
>
>
> I agree. I have no issue beyond a lack of documentation and being surprised
> I can use the word there at all and that it works exactly like "fun".
>
>
>> I haven't chucked for a while, so this could be inaccurate but I think
>> that 'public' there will just mean that you could run (perhaps by sporking,
>> or not, it's somewhat irrelevant) that function from other files once that
>> one had been loaded (and also that you couldn't redefine the function foo()
>> until you restart the VM).
>
>
> I just tried that and you can't. You can't run a "public" from another
> file, I think you are confused with "public" as it applies to classes. This;
>
> public class foo { static int bar; }
>
> can be instantiated from other files and can't be redefined until you
> restart the VM. That's fine... well it's at least documented, it's useful
> too.
>
> What "public functions" ought to be and how -if in any way- they are
> different from normal functions isn't at all clear and even after trying
> everything I could think of I can't find a single difference.
>
> At the risk of repeating myself; there is no issue with that at all
> (yet....) but it's not documented and I don't see the logic to having a
> second word, which is why I asked. I would imagine it's there as a
> place-holder for future usage but it can't hurt to ask and be sure.
>
> I'd be really happy if I *could* run them from different files, especially
> if I could also change them later, presumably on the condition that I'd keep
> the return type the same.
>
>
>
>> Also, can you not spork a function that returns something, just not access
>> the returned value?  I don't see why not.
>>
>
> No, I fear you can't. I'd explain why but as luck would have it there was a
> topic on this list on this exact subject just yesterday called "return
> values of sporked functions" where Mike & me covered this very subject. I
> recommend you look that one up in your inbox.
>
> Yours,
> Kas.
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20080608/959ceda9/attachment-0001.html>


More information about the chuck-users mailing list