![](https://secure.gravatar.com/avatar/fa5a8de5c6e6c5838fc8106b390c7a6d.jpg?s=120&d=mm&r=g)
Dear list, Sporking is fun and we can spork fun's (as long as they are of type "void") but now ( http://electro-music.com/forum/viewtopic.php?t=26805 ) it turns out that we can also spork a public. Considering that ChucKian legend has it "spork" is a slightly dirty word "public sporking" must be downright naughty, especially considering no class is needed. I'm sorry; that was too good to pass up. ========================= //the following will run, not limited in the slightest by trivialities like -say- language specifications. //note there is no class in sight public void foo() { <<<"ping">>>; } spork ~foo(); second => now; ===================== Could somebody comment on this? Is this of any use at all? well, aside from breaking the monotony of code by having synonyms? Confused, Kas.
![](https://secure.gravatar.com/avatar/e65fbeab5934976843e19fe191c44edd.jpg?s=120&d=mm&r=g)
Hi Kas,
I don't see what the problem is. You're not sporking 'a public'; surely
public is an access modifier that can apply to functions perfectly viably.
I wouldn't expect the code you posted to be illegal, although there may be
some slight redundancy. 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). Also, can you not
spork a function that returns something, just not access the returned
value? I don't see why not.
Cheers,
Peter
On Sat, Jun 7, 2008 at 11:19 AM, Kassen
Dear list,
Sporking is fun and we can spork fun's (as long as they are of type "void") but now ( http://electro-music.com/forum/viewtopic.php?t=26805 ) it turns out that we can also spork a public. Considering that ChucKian legend has it "spork" is a slightly dirty word "public sporking" must be downright naughty, especially considering no class is needed. I'm sorry; that was too good to pass up. ========================= //the following will run, not limited in the slightest by trivialities like -say- language specifications.
//note there is no class in sight public void foo() { <<<"ping">>>; }
spork ~foo();
second => now; =====================
Could somebody comment on this? Is this of any use at all? well, aside from breaking the monotony of code by having synonyms?
Confused, Kas.
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
![](https://secure.gravatar.com/avatar/fa5a8de5c6e6c5838fc8106b390c7a6d.jpg?s=120&d=mm&r=g)
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.
![](https://secure.gravatar.com/avatar/16d6ad582c31e9dc90dfc0cfd8e2ead6.jpg?s=120&d=mm&r=g)
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
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@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
participants (3)
-
Kassen
-
lucas samaruga
-
Peter Todd