[chuck-dev] feature request: ---
Michael Clemow
michaelclemow at gmail.com
Fri Dec 7 11:52:51 EST 2012
+1
That sounds pretty cool!
It seems to indicate perhaps the concept that the { } block could really be shorthand for an unnamed function. Thus, this would also be possible:
{
...
} => fun void myFun;
or even declare here, assign there, like so:
fun void myFun;
{
…
} => myFun;
the issue of return types is tricky…
you could, like in other languages use default to void, unless the block contained a return statement:
{
0 => int x;
} // function returns nothing
{
0 => int x;
return x;
} // function returns an integer
Somehow I doubt that the devs would be into this… I think that this might add execution overhead and violate the principle of something-er-other.
But even just being able to assume that a code block could be sporked as a separate shred would be pretty awesome. Still, being able to assign the shred to a variable name would be radical. "function" is an unused reserved word, right?
{
<<< "hi" >>>;
} => function hi;
spork ~ hi;
Awesome.
-Mike
--
Michael Clemow
http://michaelclemow.com
http://abattoirprojects.com
On Thursday, December 6, 2012 at 8:29 PM, Tom Lieber wrote:
> I like that alternative.
>
>
> On Thu, Dec 6, 2012 at 7:26 PM, Spencer Salazar <spencer at ccrma.stanford.edu (mailto:spencer at ccrma.stanford.edu)> wrote:
> > I think being able to spork a block of code like this:
> >
> > spork ~ {
> > // some code
> > }
> >
> > spork ~ {
> > // some other code
> > }
> >
> > would, to a lesser but still helpful degree, alleviate the issues this proposal is trying to address. It also has the benefit of recombining existing syntax rather than introducing new syntax.
> >
> > spencer
> >
> >
> >
> > On Tue, Dec 4, 2012 at 6:58 AM, Tom Lieber <tom at alltom.com (mailto:tom at alltom.com)> wrote:
> > > So you could write this:
> > >
> > > TubeBell b => dac;
> > > ---
> > > while(40::ms => now) {
> > > 1 => b.noteOn;
> > > 1600::ms => now;
> > > 1 => b.noteOff;
> > > }
> > > ---
> > > do {
> > > Std.mtof(Std.rand2(0, 3) + 60) => b.freq;
> > > } while(1640::ms => now);
> > >
> > > and have it work like this:
> > >
> > > TubeBell b => dac;
> > >
> > > fun void part1() {
> > > while(40::ms => now) {
> > > 1 => b.noteOn;
> > > 1600::ms => now;
> > > 1 => b.noteOff;
> > > }
> > > }
> > >
> > > fun void part2() {
> > > do {
> > > Std.mtof(Std.rand2(0, 3) + 60) => b.freq;
> > > } while(1640::ms => now);
> > > }
> > >
> > > spork ~ part1();
> > > spork ~ part2();
> > > day => now;
> > >
> > >
> > > --
> > > Tom Lieber
> > > http://AllTom.com/
> > > http://infinite-sketchpad.com/
> > >
> > > _______________________________________________
> > > chuck-dev mailing list
> > > chuck-dev at lists.cs.princeton.edu (mailto:chuck-dev at lists.cs.princeton.edu)
> > > https://lists.cs.princeton.edu/mailman/listinfo/chuck-dev
> > >
> >
> >
> > _______________________________________________
> > chuck-dev mailing list
> > chuck-dev at lists.cs.princeton.edu (mailto:chuck-dev at lists.cs.princeton.edu)
> > https://lists.cs.princeton.edu/mailman/listinfo/chuck-dev
> >
>
>
>
> --
> Tom Lieber
> http://AllTom.com/
> http://infinite-sketchpad.com/
> _______________________________________________
> chuck-dev mailing list
> chuck-dev at lists.cs.princeton.edu (mailto:chuck-dev at lists.cs.princeton.edu)
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-dev/attachments/20121207/79792471/attachment-0001.html>
More information about the chuck-dev
mailing list