Discussion:
{SinOsc.ar(440,0,0.1,0,'too','many','arguments')}.play
Rohan Drape
2014-08-26 03:01:26 UTC
Permalink
dear list,

what is the rationale for allowing the above?

it can make locating misplaced parenthesis somewhat more obscure than expected?

could it not print a warning?

best,
rd


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Josh Parmenter
2014-08-26 04:26:13 UTC
Permalink
There isn’t really a way (that I can think of) for checking the number of arguments in the SC language. Partly because, some methods and even functions CAN take any number of arguments, and second, I don’t think the number of expected arguments is really stored somewhere easily accessible to the external SC language.
Josh

******************************************
/* Joshua D. Parmenter
http://www.realizedsound.net/josh/ <http://www.realizedsound.net/josh/>

“Every composer – at all times and in all cases – gives his own interpretation of how modern society is structured: whether actively or passively, consciously or unconsciously, he makes choices in this regard. He may be conservative or he may subject himself to continual renewal; or he may strive for a revolutionary, historical or social palingenesis." - Luigi Nono
*/
Post by Rohan Drape
dear list,
what is the rationale for allowing the above?
it can make locating misplaced parenthesis somewhat more obscure than expected?
could it not print a warning?
best,
rd
_______________________________________________
sc-users mailing list
info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
r***@public.gmane.org
2014-08-26 05:14:45 UTC
Permalink
hello josh,

thanks for reply. in case it's only 'difficult', and not 'impossible', i added a note to:

https://github.com/supercollider/supercollider/issues/923

perhaps someone (me even) will have time to look into this at some point.

it is kind of traditional to warn about this case...

best,
rd

$ sclang
sc3> sqrt(9,16)
-> 3
$ python
import math
math.sqrt(9,16)
TypeError: sqrt() takes exactly one argument (2 given)
$ ikarus
(sqrt 9 16)
Unhandled exception &message: "incorrect number of arguments"
$ irb
irb(main):001:0> Math.sqrt(9,16)
ArgumentError: wrong number of arguments(2 for 1)
$


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Julian Rohrhuber
2014-08-26 21:30:26 UTC
Permalink
You may want to pass more arguments to a function than it uses, just as you may want to pass fewer.

f = { |a = 1, b = 1, c = 1| [a - b + c, a + b - c] };
g = { |a = 1, b = 1| [a + b, a - b] };
h = { |...args| [f, g].choose.value(*args) };

h.(8);
h.(1, 2, 3);

So a warning would (erroneously) imply that this is undesirable behaviour. But, yes, as with many things like dynamic typing, generality can make systems harder to debug, and sometimes it would be nice to have a simple (!) mechanism that allows to make dynamic systems easier to understand and safer to extend.
There isn’t really a way (that I can think of) for checking the number of arguments in the SC language. Partly because, some methods and even functions CAN take any number of arguments, and second, I don’t think the number of expected arguments is really stored somewhere easily accessible to the external SC language.
Josh
******************************************
/* Joshua D. Parmenter
http://www.realizedsound.net/josh/
“Every composer – at all times and in all cases – gives his own interpretation of how modern society is structured: whether actively or passively, consciously or unconsciously, he makes choices in this regard. He may be conservative or he may subject himself to continual renewal; or he may strive for a revolutionary, historical or social palingenesis." - Luigi Nono
*/
Post by Rohan Drape
dear list,
what is the rationale for allowing the above?
it can make locating misplaced parenthesis somewhat more obscure than expected?
could it not print a warning?
best,
rd
_______________________________________________
sc-users mailing list
info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
r***@public.gmane.org
2014-08-27 01:19:56 UTC
Permalink
hello julian,

this still seems very eccentric to me.

the traditional approach is to request this rule as required? ie.
(define (g a b) (list (+ a b) (- a b)))
(define (h . l) (apply g l))
(h 1 2)
(3 -1)
(h 1 2 3)
Unhandled exception &message: "incorrect number of arguments"
(define (g a b . unused) (list (+ a b) (- a b)))
(h 1 2 3)
(3 -1)
sclang is the only interpreter i know that is so unconcerned with arity...

i'm sure there are others, do you know one?

best,
rohan

ps. i don't think this has anything to do with typing discipline.

c, whatever you name it's discipline, allows variable arguments
but won't let you write sqrt(9,16).

#include <math.h>
double sqrt_(double n, ...) {return sqrt(n);}
main () {sqrt_(9,16);}


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
felix
2014-08-27 07:17:36 UTC
Permalink
javascript doesn't care, but then again javascript is the poster boy for
languages that annoy language connoisseurs.

» node

127 ↵
function anything(one, two) {
... console.log(one);
... console.log(two);
... }
undefined
anything(3,4,5);
3
4
undefined
hello julian,
this still seems very eccentric to me.
the traditional approach is to request this rule as required? ie.
(define (g a b) (list (+ a b) (- a b)))
(define (h . l) (apply g l))
(h 1 2)
(3 -1)
(h 1 2 3)
Unhandled exception &message: "incorrect number of arguments"
(define (g a b . unused) (list (+ a b) (- a b)))
(h 1 2 3)
(3 -1)
sclang is the only interpreter i know that is so unconcerned with arity...
i'm sure there are others, do you know one?
best,
rohan
ps. i don't think this has anything to do with typing discipline.
c, whatever you name it's discipline, allows variable arguments
but won't let you write sqrt(9,16).
#include <math.h>
double sqrt_(double n, ...) {return sqrt(n);}
main () {sqrt_(9,16);}
_______________________________________________
sc-users mailing list
http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
--
..
http://soundcloud.com/crucialfelix
http://github.com/crucialfelix
.
r***@public.gmane.org
2014-08-27 10:26:01 UTC
Permalink
hello felix,
javascript doesn't care [...]
indeed, thanks, i had no idea.

oddly javascript here is very principled, all functions are monadic!
function sqrt_(n) {return Math.sqrt(arguments[1])};
sqrt_(9,16);
4

and, since [1,2][3] isn't an error,
sqrt_(9);
NaN
[...] languages that annoy language connoisseurs.
or confuse the easily confused, or amuse the easily amused...

best,
rd


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Julian Rohrhuber
2014-08-27 10:20:45 UTC
Permalink
hello rohan,

do I understand correctly that in lisp there is an explicit 'unused' keyword that marks a lesser compatibility restriction concerning arity? There are variable arity functions in lisp, e.g. (+ 3 1 4 1 9) but I see that what you mean is that they are explicitly variable?

My main concern would certainly be an arbitrary array that is passed as arguments to a function or a method. Here, arity really should not matter in general.

e.g.
~giveMeFive = { |a = 0, b = 1, c = 2, d = 3, e = 4, f = 5| [a, b, c, d, e, f] };
~giveMeFive.(3, 4);
~giveMeFive.((0..100));

But also in the usual cases, it is at least desirable to be able to pass fewer arguments (using the default values).

As far as I understand it, dynamic typing in OOP *fully* delegates the meaning of a message to its receiver. Compatibility is decided as late as possible. This includes the selector, the arguments and, as I would say, the number of arguments. From this perspective, arity is just one (usually implicit) aspect of a function type.

Sorry, a rather exotic example, but at least an example: you may want to define sqrt on a specific number system where it is defined as ternary operator. Then you want to mix floats and those numbers in arrays you iterate over.

I would have to make a survey how arity is dealt with in languages like APL and Smalltalk. A language like C is probably not a good example in this case, because SC doesn't follow it in terms of types at all.

You are right as far as *explicitly* passed arguments are concerned (mainly because we don't use string manipulations to construct function applications in sc). The analogy would be a keword argument warning. Note though that there was some ambiguity there too, because the warning can be switched off (such modes are a problem though as we know from the inlined variable warning).

So yes, 5.sqrt(5) should probably give a warning.
Post by r***@public.gmane.org
hello julian,
this still seems very eccentric to me.
the traditional approach is to request this rule as required? ie.
(define (g a b) (list (+ a b) (- a b)))
(define (h . l) (apply g l))
(h 1 2)
(3 -1)
(h 1 2 3)
Unhandled exception &message: "incorrect number of arguments"
(define (g a b . unused) (list (+ a b) (- a b)))
(h 1 2 3)
(3 -1)
sclang is the only interpreter i know that is so unconcerned with arity...
i'm sure there are others, do you know one?
best,
rohan
ps. i don't think this has anything to do with typing discipline.
c, whatever you name it's discipline, allows variable arguments
but won't let you write sqrt(9,16).
#include <math.h>
double sqrt_(double n, ...) {return sqrt(n);}
main () {sqrt_(9,16);}
_______________________________________________
sc-users mailing list
info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
r***@public.gmane.org
2014-08-28 02:47:58 UTC
Permalink
hello julian,
Post by Julian Rohrhuber
do I understand correctly that in lisp there is an explicit 'unused'
keyword that marks a lesser compatibility restriction concerning
arity?
no, 'dotted' lists are just the notation for writing variadic
procedures, 'unused' is just a normal name, chosen to indicate the
parameter is unused. ie.
Post by Julian Rohrhuber
(define (f a b . c) (list a b c))
(f 1 2 3 4)
(1 2 (3 4))
Post by Julian Rohrhuber
f = {arg a, b ... c; [a,b,c]};
f.(1,2,3,4);
[ 1, 2, [ 3, 4 ] ]

special names can be helpful though, ie. in haskell the name '_' is
special in that it doesn't generate 'unused variable' warnings, ie.
Post by Julian Rohrhuber
let f a b c = a + b
Warning: Defined but not used: ‘c’
Post by Julian Rohrhuber
let f a b _ = a + b
f 1 2 undefined
3
Post by Julian Rohrhuber
There are variable arity functions in lisp, e.g. (+ 3 1 4 1 9) but I
see that what you mean is that they are explicitly variable?
yes, which is the same in sclang (sclang is as a lisp after all...)
Post by Julian Rohrhuber
My main concern would certainly be an arbitrary array that is passed
as arguments to a function or a method. Here, arity really should
not matter in general.
e.g.
~giveMeFive = { |a = 0, b = 1, c = 2, d = 3, e = 4, f = 5| [a, b, c, d, e, f] };
~giveMeFive.(3, 4);
~giveMeFive.((0..100));
i'm afraid i don't understand this, for sure writing less arguments is
allowed, that's what the default values are for?
Post by Julian Rohrhuber
Sorry, a rather exotic example, but at least an example: you may
want to define sqrt on a specific number system where it is defined
as ternary operator. Then you want to mix floats and those numbers
in arrays you iterate over.
i think this is a good reason, ad-hoc method signatures do require
ignoring extra arguments. i wonder what how many warnings the
standard libraries would give.

i did try writing this in order to find out, by changing
Object.perform and Object.performList, but failed.

it seems the _Primitive has to be the first entry in the method, and
deferring to another method travels via 'perform', so regresses.

perhaps this needs to be done in c, or perhaps there is a way to
bypass 'perform'.

but it's not important, lesson learned, apologies for drifting
off-topic.

best,
rohan


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Julian Rohrhuber
2014-08-29 19:45:37 UTC
Permalink
Post by r***@public.gmane.org
hello julian,
Post by Julian Rohrhuber
do I understand correctly that in lisp there is an explicit 'unused'
keyword that marks a lesser compatibility restriction concerning
arity?
no, 'dotted' lists are just the notation for writing variadic
procedures, 'unused' is just a normal name, chosen to indicate the
parameter is unused. ie.
Post by Julian Rohrhuber
(define (f a b . c) (list a b c))
(f 1 2 3 4)
(1 2 (3 4))
Post by Julian Rohrhuber
f = {arg a, b ... c; [a,b,c]};
f.(1,2,3,4);
[ 1, 2, [ 3, 4 ] ]
Ah yes, good to know.


Post by r***@public.gmane.org
Post by Julian Rohrhuber
My main concern would certainly be an arbitrary array that is passed
as arguments to a function or a method. Here, arity really should
not matter in general.
e.g.
~giveMeFive = { |a = 0, b = 1, c = 2, d = 3, e = 4, f = 5| [a, b, c, d, e, f] };
~giveMeFive.(3, 4);
~giveMeFive.((0..100));
i'm afraid i don't understand this, for sure writing less arguments is
allowed, that's what the default values are for?
Yes, my (slightly silly) example tries to show that there a cases of symmetry between less arguments and more arguments passed.
Post by r***@public.gmane.org
Post by Julian Rohrhuber
Sorry, a rather exotic example, but at least an example: you may
want to define sqrt on a specific number system where it is defined
as ternary operator. Then you want to mix floats and those numbers
in arrays you iterate over.
i think this is a good reason, ad-hoc method signatures do require
ignoring extra arguments. i wonder what how many warnings the
standard libraries would give.
I'd be curious, too. For sure it would turn out a few cases of unintentional extra arguments!
Post by r***@public.gmane.org
i did try writing this in order to find out, by changing
Object.perform and Object.performList, but failed.
it seems the _Primitive has to be the first entry in the method, and
deferring to another method travels via 'perform', so regresses.
perhaps this needs to be done in c, or perhaps there is a way to
bypass 'perform'.
would be good to know where it happens in the message interpretation, perhaps a warning would be efficient and easy to add.
Post by r***@public.gmane.org
but it's not important, lesson learned, apologies for drifting
off-topic.
I can see nothing off here! Thanks for the hints ...





_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
r***@public.gmane.org
2014-08-31 02:24:28 UTC
Permalink
hello julian,
[...] there a cases of symmetry between less arguments and more arguments passed.
but in the example there are less (two), and then less again (one)?
would be good to know where it happens in the message
interpretation, perhaps a warning would be efficient and easy to
add.
actually this behaviour is very deep, it's how we can write:

l.collect({arg e; ...});

even though collect will call the function with two arguments, etc. etc.

applying a function to too many arguments is 'common practice'.

so, slowness concerns aside, checking this at run-time isn't allowed.

still, writing Saw.ar(10,0,0.5,0.5) or sqrt(9,16) is almost certainly a mistake.

it's between phases, after parsing and before interpreting.
I can see nothing off here [...]
i think i meant that this is so obvious a strangeness that if there was
a not very complicated way about it it'd already be done, and knowing
why it's difficult doesn't really help...

best,
rohan


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Julian Rohrhuber
2014-08-31 09:23:41 UTC
Permalink
Post by r***@public.gmane.org
hello julian,
[...] there a cases of symmetry between less arguments and more arguments passed.
but in the example there are less (two), and then less again (one)?
Oh I see, that was accidental, I meant:

~giveMeFive = { |a = 0, b = 1, c = 2, d = 3, e = 4, f = 5| [a, b, c, d, e, f] };
~giveMeFive.(3, 4);
~giveMeFive.(*(0..100));
Post by r***@public.gmane.org
would be good to know where it happens in the message
interpretation, perhaps a warning would be efficient and easy to
add.
l.collect({arg e; ...});
even though collect will call the function with two arguments, etc. etc.
applying a function to too many arguments is 'common practice'.
so, slowness concerns aside, checking this at run-time isn't allowed.
still, writing Saw.ar(10,0,0.5,0.5) or sqrt(9,16) is almost certainly a mistake.
it's between phases, after parsing and before interpreting.
The code is in lang/LangPrimSource/PyrPrimitive.cpp and lang/LangPrimSource/PyrMessage.cpp

for functions, the method would be blockValue and blockValueArray, but also blockValueWithKeys and blockValueEnvirWithKeys, as it can also happen with keywords.
One could add:
if (numArgsPushed > methraw->numargs) {

for methods, it would probably be in sendMessage and sendMessageWithKeys.

But again, you are right that it may not be worth the extra if statement for each function and method call.





_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
r***@public.gmane.org
2014-08-31 22:37:58 UTC
Permalink
i don't know how f.(*l) is re-written, but in theory i think
it's the same as lisp distinction of
(+ 1 2 3)
(apply + (list 1 2 3))
it may not be worth the extra if statement for each function
(1..10).collect({|n| n.squared});
and so on, but perhaps for methods. i'll try it out.

thanks,
rohan


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Julian Rohrhuber
2014-09-01 08:32:36 UTC
Permalink
Post by r***@public.gmane.org
i don't know how f.(*l) is re-written, but in theory i think
it's the same as lisp distinction of
(+ 1 2 3)
(apply + (list 1 2 3))
f.(*l) is a shortcut for f.valueArray(l)

If you want to iteratively apply a function to items in a list, there is reduce:

l.reduce(f)
l.reduce('+')

It assumes a binary function though.
Post by r***@public.gmane.org
it may not be worth the extra if statement for each function
(1..10).collect({|n| n.squared});
a good example, yes: the function in collect is assumed to be up to binary (it may have two, one or zero arguments), but always two arguments are passed. So you'd get a warning for the above if one would detect the case where more arguments are passed than given. I wonder how other languages that are 'stricter' work around this in such cases.


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
r***@public.gmane.org
2014-09-02 02:33:54 UTC
Permalink
hello julian,
Post by Julian Rohrhuber
Post by r***@public.gmane.org
i don't know how f.(*l) is re-written, but in theory i think
it's the same as [the] lisp distinction of
(+ 1 2 3)
(apply + (list 1 2 3))
f.(*l) is a shortcut for f.valueArray(l)
thanks, it's the same meaning then, ie. valueArray is lisp's apply.

and it has precisely two arguments, so i think sclang symmetry is not
quite as you suggested, it's more like the javascript model?
i wasn't clear about this, apologies. the two expressions i typed
above are equal. reduce is one of what lisps call the 'fold' family.
Post by Julian Rohrhuber
I wonder how other languages that are 'stricter' work around this in
such cases.
i think you have one or the other, there's no 'working around'. if by
'stricter' you mean hindley/milner etc. the types are required to
align, you have to pass 'collect' a function of two arguments. i
guess the special name '_' for unused arguments is a work around of
sorts, depending on how you look at it.

but here it's two aspects of the same thing, ie.
Post by Julian Rohrhuber
[9,16].collect(_.sqrt) == [3,4]
sqrt(9,0) == 3
knowing the former i shouldn't've been suprised about the latter...

best,
rohan


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Julian Rohrhuber
2014-09-02 08:55:26 UTC
Permalink
Post by r***@public.gmane.org
hello julian,
Post by Julian Rohrhuber
Post by r***@public.gmane.org
i don't know how f.(*l) is re-written, but in theory i think
it's the same as [the] lisp distinction of
(+ 1 2 3)
(apply + (list 1 2 3))
f.(*l) is a shortcut for f.valueArray(l)
thanks, it's the same meaning then, ie. valueArray is lisp's apply.
yes, so the (*) syntax makes sc calls lispier so to say.
Post by r***@public.gmane.org
and it has precisely two arguments, so i think sclang symmetry is not
quite as you suggested, it's more like the javascript model?
You mean the symmetry between arity and typing? Btw. historically, dynamic typing of functions goes back at least to combinatory logic of the 1920, distinguishing arity was used to categorise statements for decision procedures. So the perspective I proposed is one that seems to be more evident from the Smalltalk perspective, where even the identity of the function becomes context dependent.

What would be the javascript model?

valueArray takes a variable number of arguments:

valueArray { arg ... args;
_FunctionValueArray
// evaluate a function, if the last argument is an array it will be
// expanded into separate args.
^this.primitiveFailed
}

{ |a, b| [a, b] }.valueArray([1, 2, 3, 4]); // -> [1, 2]
{ |a, b| [a, b] }.valueArray([1, 2, 3, 4], [1, 2, 3, 4]); // -> [ [ 1, 2, 3, 4 ], 1 ]
(actually I didn't know you could do this)

But what I meant was rather that you could (conventions aside):
- define a method on different objects with a variable arity
- call the method with any number of arguments you like

<…>
Post by r***@public.gmane.org
Post by Julian Rohrhuber
I wonder how other languages that are 'stricter' work around this in
such cases.
i think you have one or the other, there's no 'working around'. if by
'stricter' you mean hindley/milner etc. the types are required to
align, you have to pass 'collect' a function of two arguments. i
guess the special name '_' for unused arguments is a work around of
sorts, depending on how you look at it.
In a way it is an interesting case, because types in type inference systems can be partly generalised and the functions they select are selected by a pattern matching of some sort. But conceptually, arity is a type, just of a higher order (T^arity if you want).
Post by r***@public.gmane.org
but here it's two aspects of the same thing, ie.
Post by Julian Rohrhuber
[9,16].collect(_.sqrt) == [3,4]
sqrt(9,0) == 3
knowing the former i shouldn't've been suprised about the latter...
Now that example makes it really concise - yes!







_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
r***@public.gmane.org
2014-09-03 02:23:26 UTC
Permalink
hello julian,
Post by Julian Rohrhuber
so the (*) syntax makes sc calls lispier so to say.
sorry i'm so unclear. i meant to say that writing the '*' is the same
as writing the 'apply', ie. that there are two distinct notations
involved. i fear the lisp angle was confusing, i was trying to work
out if there was some _actual_ difference here that i don't
understand.
Post by Julian Rohrhuber
You mean the symmetry between arity and typing?
no, i was thinking of your comment that there was a "symmetry between
less arguments and more arguments passed" and i'm not sure there is.

writing too few arguments, ie. "SinOsc.ar * 0.1", can mean either "use
the default values, they're fine" or "i've made a mistake".

writing too many arguments, ie. "Pulse.ar(440,0,0.5,0,0.1)", i _think_
always means "i've made a mistake", here perhaps because LFPulse has
an initial phase argument and Pulse doesn't.
Post by Julian Rohrhuber
Btw. historically, dynamic typing of functions goes back at least to
combinatory logic of the 1920, distinguishing arity was used to
categorise statements for decision procedures. So the perspective I
proposed is one that seems to be more evident from the Smalltalk
perspective, where even the identity of the function becomes context
dependent.
i'm not sure about this, there are all sorts of ways of deciding what
a name refers to, but functions, by definition, shouldn't be context
dependent? but this is definitely drifting...
Post by Julian Rohrhuber
What would be the javascript model?
felix pointed this out, see

http://article.gmane.org/gmane.comp.audio.supercollider.user/109483
yes, apologies, i looked at AbstractDispatcher.valueArray, which
seemed promising... but as you note, for our purposes it's almost the
same
Post by Julian Rohrhuber
- define a method on different objects with a variable arity
- call the method with any number of arguments you like
but there is still an important distinction, a function either means
something when applied to a 'list' or it doesn't? it seems obscure to
write:

{arg a, b; (a * a) + (b * b)}.(*[3,4])

since every list that is not a list of two numbers is an error, for
some definition of error. and there is no general way of deriving a
list variant of the function.
Post by Julian Rohrhuber
In a way it is an interesting case, because types in type inference =
systems can be partly generalised and the functions they select are =
selected by a pattern matching of some sort. But conceptually, arity is =
a type, just of a higher order (T^arity if you want).
they like to call higher order types kinds, which is nice.

but i don't think we need kinds here? in relation to functions, arity
can be made to disappear?

ie. (a,b)->c <==> a->b->c

ie. http://en.wikipedia.org/wiki/Currying

best,
rohan


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Julian Rohrhuber
2014-09-09 10:28:49 UTC
Permalink
Post by r***@public.gmane.org
Post by Julian Rohrhuber
You mean the symmetry between arity and typing?
no, i was thinking of your comment that there was a "symmetry between
less arguments and more arguments passed" and i'm not sure there is.
writing too few arguments, ie. "SinOsc.ar * 0.1", can mean either "use
the default values, they're fine" or "i've made a mistake".
writing too many arguments, ie. "Pulse.ar(440,0,0.5,0,0.1)", i _think_
always means "i've made a mistake", here perhaps because LFPulse has
an initial phase argument and Pulse doesn't.
Yes, this is correct in the case of a function call where arguments are explicitly written - I think we should fix this case with a warning.

Passing an array argument and expanding it is something different though, because the intention is a more general one?
Post by r***@public.gmane.org
Post by Julian Rohrhuber
Btw. historically, dynamic typing of functions goes back at least to
combinatory logic of the 1920, distinguishing arity was used to
categorise statements for decision procedures. So the perspective I
proposed is one that seems to be more evident from the Smalltalk
perspective, where even the identity of the function becomes context
dependent.
i'm not sure about this, there are all sorts of ways of deciding what
a name refers to, but functions, by definition, shouldn't be context
dependent? but this is definitely drifting...
Yes, strictly speaking I meant the "selector" (it is just from a formal perspective that it "is" the function).

But in Smalltalk-like OOP, there are only messages and objects (i.e. selectors and arguments), and an object is essentially a full message interpreter. Thus, the function call is context dependent. Speaking in functional programming terms, the first argument is a function that maps the selector to a function that takes the rest of the arguments.

In the history of combinatory logic, arity was important for finding a decision procedure. But, in a dynamically typed system in particular, we are not writing programs as proofs really (or maybe in another sense?).
Post by r***@public.gmane.org
Post by Julian Rohrhuber
- define a method on different objects with a variable arity
- call the method with any number of arguments you like
but there is still an important distinction, a function either means
something when applied to a 'list' or it doesn't? it seems obscure to
{arg a, b; (a * a) + (b * b)}.(*[3,4])
since every list that is not a list of two numbers is an error, for
some definition of error. and there is no general way of deriving a
list variant of the function.
- in a wider context, this function may come with other functions that take more arguments:

f = { arg a, b; (a * a) + (b * b)};
g = { arg a, b, precision = 0| (a * a * precision.rand) + (b * b * precision.rand) };
[f, g, f, f, g, f].collect { arg func, i; func.(*[i, i + 1, 0.2]) };

- it is easy to write a function that derives a list variant from any function:
l = { arg func; { arg list; func.valueArray(list) } };
a = l.(f);
a.([3, 4]);

- you can even add arity checking yourself:
(
l = { arg func;
{ arg list;
if(list.size > func.def.argNames.size) { "too many arguments".warn };
func.valueArray(list)
}
};
)
Post by r***@public.gmane.org
Post by Julian Rohrhuber
In a way it is an interesting case, because types in type inference =
systems can be partly generalised and the functions they select are =
selected by a pattern matching of some sort. But conceptually, arity is =
a type, just of a higher order (T^arity if you want).
they like to call higher order types kinds, which is nice.
but i don't think we need kinds here? in relation to functions, arity
can be made to disappear?
ie. (a,b)->c <==> a->b->c
ie. http://en.wikipedia.org/wiki/Currying
Interesting step - yes, possibly arity disappears into the reasoning chain. So our discussion regarding the call exceeding the function arity boils down to the case where, once the function returned is nullary, it is still called with one argument a number of times, always returning itself (if that is allowed). So the basic question seems to be: does a lack of (input) type map to nothing or to everything?

In OOP messaging, the receiver would map the message selector (function name) to a function and pass the rest of the arguments to it. I'm not sure if this asymmetry permits an equivalent of currying, certainly it is not trivial. Dispatch works a bit like that (e.g. x + 7 where x is an array, maps to the array of each elemnt + 7).








_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
r***@public.gmane.org
2014-09-11 00:23:04 UTC
Permalink
hello julian,
Post by Julian Rohrhuber
Passing an array argument and expanding it is something different
though, because the intention is a more general one?
i don't understand this?

i undestand variadic functionss as a sort of notational convenience, so
you can write f.value(p,q,r...) instead of f.value([p,q,r...]).

in sc it hardly seems worth it, in lisp it's more necessary, ie.
compare (f 1 2 3) and (f (cons 1 (cons 2 (cons 3 nil)))).

ie. the lisp notation is simply too awkward without variadic
procedures, ie. you at the very least want the standard variadic
"list" function, ie. (list 1 2 3) => (cons 1 (cons 2 (cons 3 nil)))
and after you make the mechanism...

curiously, if you write a lisp where functions are strictly a->b then
you have to write "list" as a macro, but the notational rationale
stays the same.
Post by Julian Rohrhuber
But in Smalltalk-like OOP, there are only messages and objects [...]
i'm not sure this is connected? my, very incomplete, knowledge of the
history of all this is from felleisen:

http://lists.racket-lang.org/users/archive/2009-April/032444.html

i think this means that smalltalk can be viewed as a (rather nice)
notation for a family of "lisp" programs, ie. that:

SinOsc.ar(440,0)

can be, properly, translated to:

((resolve-method "ar" SinOsc) 440 0)

that is, a method is a name that is "resolved" to a procedure.

i'm pretty sure that methods, particularly in smalltalk, don't touch
the issue of arity, which is a property of the procedure.
Post by Julian Rohrhuber
it is easy to write a function that derives a list variant from any =
yes, but the function you derive in this way only works if the list
has the required shape?

i meant that there's no "natural" transformation, that takes a
"complete" (non-partial) function and derives a list variant (this is
obvious?)

ie. the "canonical" lisp variadic functions (+,*,etc.) are special
cases, and again i think are there for notational reasons. ie.
writing 1 + 2 + 3 + 4 is fine but writing (+ (+ (+ 1 2) 3) 4) isn't.
it's not nice reading either...
Post by Julian Rohrhuber
So our discussion regarding the call exceeding the function arity
boils down to the case where, once the function returned is nullary,
it is still called with one argument a number of times, always
returning itself (if that is allowed). So the basic question seems
to be: does a lack of (input) type map to nothing or to everything?
but this isn't what happens? in that notation all functions are
monadic (unary), a reduction for plus would be:

+ : int -> int -> int
+ 1 : int -> int
+ 1 2 : int

ie. you never get a "nullary" procedure (and of course you can't have
a nullary "function"), you get a value.

writing "+ 1 2 3" here is the same as writing "3 3" which is an error
because "3" isn't a function ("a -> b"), it's an "int".

perhaps the notational implications of this are non-obvious? at least
they were to me. lisp _has_ to write function application
parenthetically because it has procedures that can have any number
(even a variable number) of arguments. if all procedures are unary
you can write function application using "infix white space" as ml
etc. does, ie.

c: f(p,q)
sc: f.value(p,q)
lisp: (f p q)
ml: f p q

this is connected to why you dont get lisp when you write forth
backwards!

(thinking carefully about writing forth backwards is actually quite
interesting... but forth too is interesting, "1 2 + 3 + 4 +" is not
as problematic as the lisp form)

best,
rohan


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
r***@public.gmane.org
2014-09-11 00:37:08 UTC
Permalink
Post by r***@public.gmane.org
i undestand variadic functionss as a sort of notational convenience, so
my goodness, i can't type this morning...

undestand -> understand
functionss -> functions


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Julian Rohrhuber
2014-09-11 09:37:33 UTC
Permalink
hello rohan,
Post by r***@public.gmane.org
Post by Julian Rohrhuber
Passing an array argument and expanding it is something different
though, because the intention is a more general one?
i don't understand this?
i undestand variadic functionss as a sort of notational convenience, so
you can write f.value(p,q,r...) instead of f.value([p,q,r...]).
in sc it hardly seems worth it, in lisp it's more necessary, ie.
compare (f 1 2 3) and (f (cons 1 (cons 2 (cons 3 nil)))).
I think it isn't just a notational convenience, at least on the level of a running program.

In SC, general variadic function calls (like valueArray and valueEnvir) used in cases where the arguments are kept together in one data structure (an array or an environment). In such cases, the degree of specification may vary arbitrarily, and various levels of default values can fill in the gaps at their appropriate level. Also, some functions that pass both selector and argument don't know about the arity of the selected method, so they need to use valueArray.

Of course writing f.(*array) instead of f.valueArray(array) is a notational convenience for sure.
Post by r***@public.gmane.org
Post by Julian Rohrhuber
But in Smalltalk-like OOP, there are only messages and objects [...]
i'm not sure this is connected? my, very incomplete, knowledge of the
http://lists.racket-lang.org/users/archive/2009-April/032444.html
An interesting thread.
Post by r***@public.gmane.org
i think this means that smalltalk can be viewed as a (rather nice)
SinOsc.ar(440,0)
((resolve-method "ar" SinOsc) 440 0)
that is, a method is a name that is "resolved" to a procedure.
Yes, this is how I think about them, too. What seems only a subset becomes a rather radical change, I suppose, if you take the "resolving" as part of the runtime process. Here is what Alan Kay wrote and still puzzles me (I'd love to understand things better from the side of development of Lisps/Schemes).

"By this, I mean that the pure language was supposed to be based on functions, but its most important components--such as iambda expressions, quotes, and conds--were not functions at all, and instead were called special forms. Landin and others had been able to get quotes and conds in terms of lambda by tricks that were variously clever and useful, but the flaw remained in the jewel. In the practical language things were better. There were not just EXPRS (which evaluated their arguments), but FEXPRS (which did not). My next question was, why on earth call it a functional language? Why not just base everything on FEXPRS and force evaluation on the receiving side when needed? I could never get a good answer, but the question was very helpful when it came time to invent Smalltalk, because this started a line of thought that said "take the hardest and most profound thing you need to do, make it great, and then build every easier thing out of it." That was the promise of LISP and the lure of lambda needed was a better "hardest and most profound" thing. Objects should be it." (History of Programming Languages II, 524)
Post by r***@public.gmane.org
i'm pretty sure that methods, particularly in smalltalk, don't touch
the issue of arity, which is a property of the procedure.
Exactly. Still, abstracting from arity is a somewhat special territory.
Post by r***@public.gmane.org
Post by Julian Rohrhuber
it is easy to write a function that derives a list variant from any =
yes, but the function you derive in this way only works if the list
has the required shape?
i meant that there's no "natural" transformation, that takes a
"complete" (non-partial) function and derives a list variant (this is
obvious?)
I think I know what you mean. What my example does is to simply pass any number of arguments to the specified function and let it care for a "mismatch" of arguments. So it will work for any shape if there are default arguments in the function (or you provide them in the wrapper). It will call this function once on whatever arguments are given. Your example uses a binary function to recursively consume the arguments with it.

In sc, this would be:

[1, 2, 3, 4, 5].reduce('+')
[1, 2, 3, 4, 5].reduce({ |x, y| x ** neg(y) })

Unfortunately, I implemented reduce only as a method for binary functions or operators. After this discussion I'd love to generalise it (and wonder if it is possible without breaking code!). For selectors it may be difficult, because each subsequent receiver may (in some cases) have a different arity.
Post by r***@public.gmane.org
Post by Julian Rohrhuber
So our discussion regarding the call exceeding the function arity
boils down to the case where, once the function returned is nullary,
it is still called with one argument a number of times, always
returning itself (if that is allowed). So the basic question seems
to be: does a lack of (input) type map to nothing or to everything?
but this isn't what happens? in that notation all functions are
+ : int -> int -> int
+ 1 : int -> int
+ 1 2 : int
ie. you never get a "nullary" procedure (and of course you can't have
a nullary "function"), you get a value.
writing "+ 1 2 3" here is the same as writing "3 3" which is an error
because "3" isn't a function ("a -> b"), it's an "int".
Yes, so that was what I meant: there are two types of fundamental entities here, functions and values. A value "functions" as a nullary function in that it does not permit any application. In lambda calculus, everything is a function, so this is why ("In Lisp, nearly everything is a function"). On "everything is a function": http://conal.net/blog/posts/everything-is-a-function-in-haskell

Surely this is a design choice - one distinguishes the leaves from the branches so to say. This is not necessarily a bad one, because the meaning of 3 3 is indeed obscure. This is a distinction that (at least in principle) disappears with object orientation, because everything is of one elementary typeless "type".
Post by r***@public.gmane.org
perhaps the notational implications of this are non-obvious? at least
they were to me. lisp _has_ to write function application
parenthetically because it has procedures that can have any number
(even a variable number) of arguments. if all procedures are unary
you can write function application using "infix white space" as ml
etc. does, ie.
c: f(p,q)
sc: f.value(p,q)
lisp: (f p q)
ml: f p q
this is connected to why you dont get lisp when you write forth
backwards!
Yes, that is something that really blocked my understanding of Haskell for a while, especially when you combine more function calls into one expression without any brackets.
Post by r***@public.gmane.org
(thinking carefully about writing forth backwards is actually quite
interesting... but forth too is interesting, "1 2 + 3 + 4 +" is not
as problematic as the lisp form)
There are indeed advantages of reverse Polish notation, even if it really looks strange. It is a bit like cooking, the eating is always at the end.






_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
r***@public.gmane.org
2014-09-13 05:01:20 UTC
Permalink
hello julian,
Post by Julian Rohrhuber
I think it isn't just a notational convenience, at least on the level of a running program.
on the specific question of "variable arity", i still don't really
understand. what is the difference between:

f = {arg ...l; l.size + 1};
g = {arg l; l.size + 1};

except that you write:

f.value(1,2,3) == 4
g.value([1,2,3]) == 4

it seems to me that f & g are both functions over lists (and in this
case total functions) and you just write the list differently.

of course notation is really important, i'm not trying to suggest it
isn't...
Post by Julian Rohrhuber
Also, some functions that pass both selector and argument don't know
about the arity of the selected method, so they need to use
valueArray.
yes. but you can write the "list apply" function without variadic
functions, it's a long function to write because you need to enumerate
all of the cases you're interested in, but you can do it, ie.

[] -> f.value()
[p] -> f.value(p)
[p,q] -> f.value(p,q)
[p,q,r] -> f.value(p,q,r)
...

i mean, this will cover the case of wanting to apply "plus" or
"sum-of-squares" to a list, etc. and it's enough to write an
arity-generic map (collect) etc. you don't need variadic functions
for this?
Post by Julian Rohrhuber
Here is what Alan Kay wrote and still puzzles me (I'd love to
understand things better from the side of development of
Lisps/Schemes).
i think that aligns with the felleisen comment? the
post-smalltalk/actors lisps (ie. scheme) are not the same as the
pre-smalltalk lisps. it's in the nature of scheme that you have to
write the "smalltalk" rules as a library...

of course felleisen doesn't say if actors is a good model of
smalltalk, or how well sussman & steele understood actors...

another nice 'history' of that period is olin shivers & jonathan rees
on T, ie: http://mumble.net/~jar/tproject/

it's neccesarily a narrow view, and knows it, ie. "The Europeans
working on early systems like ML in Edinburgh probably find all this
American early-80's thrashing & confusion over scoping discipline and
implementation strategy incredibly clueless. Sorry 'bout that."
Post by Julian Rohrhuber
Unfortunately, I implemented reduce only as a method for binary
functions or operators.
i'm not sure this is unfortunate! i think it's the nature of folds?
i'm afraid i still may not have been very clear.

perhaps clearer:

there are functions that are properly list functions, such as size
(length) and collect (map) and reverse and reduce (foldl0) and reject
(filter) and sum etc. etc. (where a list is a variable length
sequence)

and then there are functions that are properly 'tuple' functions,
ie. +, round, absdif, etc. etc. (where a tuple is a fixed length
sequence).

variadic functions and "list apply" interchange the notations, but the
functions are still of one sort or the other.

"list apply" gives you generic map, but the reverse seems an odd thing
to do?

i figure there has to be some reason for all of this, but i don't
think i know what it is. (except, as mentioned before, that in lisp
the notational reasons in some few cases are compelling).

of course in ml etc. you can't write either of these.

the obvious "notational" cost is that you have, for instance, to write
out the map/zipWith family etc. or use an "Applicative" type infix
notation.

actually it's possible to avoid having to write out the family of
functions, but as far as i know you still need to write the arity into
the expression, ie. there is still a notational 'excess', see
http://www.seas.upenn.edu/~sweirich/papers/aritygen.pdf
Post by Julian Rohrhuber
Yes, so that was what I meant: there are two types of fundamental
entities here, functions and values.
i wrote poorly there, of course functions are values, and integers are
values, but integers are not functions...
Post by Julian Rohrhuber
This is a distinction that (at least in principle) disappears with
object orientation, because everything is of one elementary typeless
"type".
actually, i recall rees also asked interesting questions about oo, and
received interesting answers:

http://www.eros-os.org/pipermail/e-lang/2001-October/005852.html

i never really knew what to make of any of this, and retreated into
pure term rewriting, which i can follow well enough.

the typeless type is a mystery to me. it still seems to go wrong in
all the same ways as the typeful type.

3.reverse
"x".negate
Post by Julian Rohrhuber
There are indeed advantages of reverse Polish notation, even if it
really looks strange.
i've often wondered about this. i'm not super averse to lisp
notation, and forth hardly seems worse. as a gift, and to
procrastinate, and to find out, i wrote a very simple forth
interpreter that only knows about supercollider unit generators and
translated various sc2 examples. i think, as a notation, it's not too
awful.

http://rd.slavepianos.org/?t=hsc3-forth

there's a lisp in the same vein, hence the fahey "american primitive"
references. in relation to this thread, the lisp has strictly
unary/monadic lambda, & runs the exact same graph codes as the actual
scheme supercollider bindings, which is perhaps sort of interesting.

http://rd.slavepianos.org/?t=hsc3-lisp
Post by Julian Rohrhuber
It is a bit like cooking, the eating is always at the end.
it also reminds of mark twain, "Whenever the literary German dives
into a sentence, that is the last you are going to see of him till he
emerges on the other side of his Atlantic with his verb in his mouth."

best,
rohan


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Julian Rohrhuber
2014-09-24 20:29:38 UTC
Permalink
hello rohan,
Post by r***@public.gmane.org
Post by Julian Rohrhuber
I think it isn't just a notational convenience, at least on the level of
a running program.
on the specific question of "variable arity", i still don't really
f = {arg ...l; l.size + 1};
g = {arg l; l.size + 1};
f.value(1,2,3) == 4
g.value([1,2,3]) == 4
it seems to me that f & g are both functions over lists (and in this
case total functions) and you just write the list differently.
I'm not sure I understand, but I try to remember what I meant.
So the idea of variable arity in the call (not in the definition) occurred where you have different, explicitly named arguments. You can bind values to these arguments by passing an array to valueArray (abbreviated by *), which may have fewer values (no problem), but also more.

The example would be:
x = [440,0,0.1,0,'too','many','arguments'];
SinOsc.ar(*x);

If the argument definitions are generic enough, this may make sense. In the above case, there may be reasons to be unhappy about this way of putting it (different *ar methods have different semantics).
Post by r***@public.gmane.org
Post by Julian Rohrhuber
Also, some functions that pass both selector and argument don't know
about the arity of the selected method, so they need to use
valueArray.
yes. but you can write the "list apply" function without variadic
functions, it's a long function to write because you need to enumerate
all of the cases you're interested in, but you can do it, ie.
[] -> f.value()
[p] -> f.value(p)
[p,q] -> f.value(p,q)
[p,q,r] -> f.value(p,q,r)
...
i mean, this will cover the case of wanting to apply "plus" or
"sum-of-squares" to a list, etc. and it's enough to write an
arity-generic map (collect) etc. you don't need variadic functions
for this?
Well, I still sense that arity and type are somewhat related, and may be even treated on the same level - your example seems to support this: it looks just like pattern matching on type.
Post by r***@public.gmane.org
Post by Julian Rohrhuber
Here is what Alan Kay wrote and still puzzles me (I'd love to
understand things better from the side of development of
Lisps/Schemes).
i think that aligns with the felleisen comment? the
post-smalltalk/actors lisps (ie. scheme) are not the same as the
pre-smalltalk lisps. it's in the nature of scheme that you have to
write the "smalltalk" rules as a library...
of course felleisen doesn't say if actors is a good model of
smalltalk, or how well sussman & steele understood actors...
Ah yes, I see. So far I had assumed that Scheme was mainly a reduction of Lisp (http://c2.com/cgi/wiki?LispSchemeDifferences), but this seems not to be the core of it (http://en.wikipedia.org/wiki/History_of_the_Scheme_programming_language). Apparently it is the possibility of writing in continuation passing style that is the main addition?
Post by r***@public.gmane.org
another nice 'history' of that period is olin shivers & jonathan rees
on T, ie: http://mumble.net/~jar/tproject/
it's neccesarily a narrow view, and knows it, ie. "The Europeans
working on early systems like ML in Edinburgh probably find all this
American early-80's thrashing & confusion over scoping discipline and
implementation strategy incredibly clueless. Sorry 'bout that."
A very interesting source, thank you!
Post by r***@public.gmane.org
Post by Julian Rohrhuber
Unfortunately, I implemented reduce only as a method for binary
functions or operators.
i'm not sure this is unfortunate! i think it's the nature of folds?
Well, for a moment I thought one could make the arity of fold depend on the selector you pass:

[1, 2, 3, 4, 5].reduce { |a, b, c| a * b - c };

1 * 2 - 3 => -1
-1 * 4 - 5 => -9

But, if you pass a selector instead of a function, the method's arity depends on the object it calls. Still, possible, but possibly confusing.
Post by r***@public.gmane.org
i'm afraid i still may not have been very clear.
there are functions that are properly list functions, such as size
(length) and collect (map) and reverse and reduce (foldl0) and reject
(filter) and sum etc. etc. (where a list is a variable length
sequence)
and then there are functions that are properly 'tuple' functions,
ie. +, round, absdif, etc. etc. (where a tuple is a fixed length
sequence).
variadic functions and "list apply" interchange the notations, but the
functions are still of one sort or the other.
"list apply" gives you generic map, but the reverse seems an odd thing
to do?
i figure there has to be some reason for all of this, but i don't
think i know what it is. (except, as mentioned before, that in lisp
the notational reasons in some few cases are compelling).
of course in ml etc. you can't write either of these.
the obvious "notational" cost is that you have, for instance, to write
out the map/zipWith family etc. or use an "Applicative" type infix
notation.
actually it's possible to avoid having to write out the family of
functions, but as far as i know you still need to write the arity into
the expression, ie. there is still a notational 'excess', see
http://www.seas.upenn.edu/~sweirich/papers/aritygen.pdf
Exactly, the abstract of the article is also a good way of putting it. As you know, in dynamically typed OOP, you avoid it by, well, by not having types in the signatures of the methods. Maybe AbstractFunction is a good place:

composeNAryOp { arg aSelector, anArgList;
^NAryOpFunction.new(aSelector, this, anArgList)
}
Post by r***@public.gmane.org
Post by Julian Rohrhuber
Yes, so that was what I meant: there are two types of fundamental
entities here, functions and values.
i wrote poorly there, of course functions are values, and integers are
values, but integers are not functions...
Hm, I had suspected that integers are a function that return themselves or something like that. But that was thinking it too much from a mathematical angle I suppose.
Post by r***@public.gmane.org
Post by Julian Rohrhuber
This is a distinction that (at least in principle) disappears with
object orientation, because everything is of one elementary typeless
"type".
actually, i recall rees also asked interesting questions about oo, and
http://www.eros-os.org/pipermail/e-lang/2001-October/005852.html
His points of critique of OOP are interesting and worth repeating here:

- It accounts poorly for symmetric interaction, such as chemical
reactions and gravity.

- It deals poorly with information-oriented phenomena such as
mathematical objects, copying, broadcast, encryption, caching, and
signing. E takes a step in the right direction by introducing the
"selfless" notion, but this isn't enough.

- It usually has a very imperative, operational flavor to it.
It begs you to write a recipe, not to describe the result that you
want as functional languages do. This isn't really inherent, and E
is much better on this count than C++/Java.

- It forces you to always decide who's on top in any interaction,
i.e. which object should define the method, a decision that's not
always easy and one that you often want to change.

- It's a poor match both syntactically and semantically with
natural language, making it awkward for expressing things that are
in people's minds.

Would make an interesting discussion!
Post by r***@public.gmane.org
i never really knew what to make of any of this, and retreated into
pure term rewriting, which i can follow well enough.
the typeless type is a mystery to me. it still seems to go wrong in
all the same ways as the typeful type.
3.reverse
"x".negate
oh yes, indeed, and the possibility of going wrong may be simply a consequence of logical incompleteness.
Practically, I often wonder if there is could be a way to improve the situation about polymorphic misunderstanding (or separate between the good and the bad cases).
Post by r***@public.gmane.org
Post by Julian Rohrhuber
There are indeed advantages of reverse Polish notation, even if it
really looks strange.
i've often wondered about this. i'm not super averse to lisp
notation, and forth hardly seems worse. as a gift, and to
procrastinate, and to find out, i wrote a very simple forth
interpreter that only knows about supercollider unit generators and
translated various sc2 examples. i think, as a notation, it's not too
awful.
http://rd.slavepianos.org/?t=hsc3-forth
quite beautiful! A proper knitting-machine for signal-knots...
I still try to understand what it actually does :)
Post by r***@public.gmane.org
there's a lisp in the same vein, hence the fahey "american primitive"
references. in relation to this thread, the lisp has strictly
unary/monadic lambda, & runs the exact same graph codes as the actual
scheme supercollider bindings, which is perhaps sort of interesting.
http://rd.slavepianos.org/?t=hsc3-lisp
Post by Julian Rohrhuber
It is a bit like cooking, the eating is always at the end.
it also reminds of mark twain, "Whenever the literary German dives
into a sentence, that is the last you are going to see of him till he
emerges on the other side of his Atlantic with his verb in his mouth."
There are people here who can keep audiences busy exactly in this way, enjoyable and distressing at the same time!





_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
r***@public.gmane.org
2014-09-27 01:42:14 UTC
Permalink
hello julian,

we seem to have left the initial topic well behind.

but i think there was a conclusion of sorts, ie.

- supercollider functions ignore "extra" arguments, this is not by
accident but design, it allows 'collect' and family to provide
"optional" indices, etc.

- this rule, in combination with default values, and in particular the
default default value of "nil", means that all supercollider
functions allow any number of arguments

- it may be possible to warn about cases where "too many parameters"
are written into the "text", but it's not trivial

getting to the off-topic (but interesting) parts...
Post by Julian Rohrhuber
If the argument definitions are generic enough, this may make sense.
i think we mean the same thing, my idea is precisely that "If the
argument definitions are generic enough" means that the function is
properly a "list processing function" and might just as well be
written that way.

it's "notational" in different way than in c & ml etc. (because
there's no standard notation for heterogenous lists) and for lisp &
scheme etc. (because the notation for heterogenous lists is precisely
a variadic function).
Post by Julian Rohrhuber
Well, I still sense that arity and type are somewhat related, and may be
even treated on the same level - your example seems to support this: it
looks just like pattern matching on type.
again, i think we mean the same thing.

in scheme etc. (and supercollider) multiple arguments _are_ the
"notation" for functions over "product types".

in ml etc., where there is a direction notation for these, it's very
clear that multiple arguments are only a "syntax".

(it's particularly clear when you see that the type of the "primitive"
fixed-precision-integral-adder-with-carry in ghc is "int -> int ->
(int,int)" rather than "(int,int) -> (int,int)".)

(the fifth revision of scheme introduced "multiple return values",
which are the other side of this equation.)

http://people.csail.mit.edu/jaffer/r5rs_8.html#IDX423
Post by Julian Rohrhuber
[1, 2, 3, 4, 5].reduce { |a, b, c| a * b - c };
1 * 2 - 3 =3D> -1
-1 * 4 - 5 =3D> -9
But, if you pass a selector instead of a function, the method's arity
depends on the object it calls. Still, possible, but possibly confusing.
i think so, but then i would... scheme's "fold" does allow the
function to have more than two arguments, but the rule is that then
you need to provide more than one "list", ie.

http://www.r6rs.org/final/html/r6rs-lib/r6rs-lib-Z-H-4.html#node_idx_212
Post by Julian Rohrhuber
Hm, I had suspected that integers are a function that return themselves
or something like that.
i don't think you can define that in ml etc.
Post by Julian Rohrhuber
let f _ = f
<interactive>:8:11: Occurs check: cannot construct the infinite type: t1 ~ t -> t1

you can in scheme & supercollider etc. but what to do with it?

sc3> f = {f};
-> a Function
sc3> f.();
-> a Function
sc3> f.() == f;
Post by Julian Rohrhuber
But that was thinking it too much from a mathematical angle I
suppose.
you can do this, ie. http://en.wikipedia.org/wiki/Church_encoding

but even so (ie. if Integer is encoded as a function) there's still a
distinction between "f : Integer -> Integer" and "g : Integer"
Post by Julian Rohrhuber
Practically, I often wonder if there is could be a way to improve the
situation about polymorphic misunderstanding (or separate between the
good and the bad cases).
i guess f-omega and related are an attempt at that?

http://en.wikipedia.org/wiki/System_F#System_F.CF.89

best,
rohan


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Monsieur
2014-10-02 12:19:46 UTC
Permalink
HI,
Post by Julian Rohrhuber
Hm, I had suspected that integers are a function that return themselves
or something like that.
Maybe he is talking about :

f = { "true function" }
f.value
-> "true function"

42.value
-> 42

you can call the value method on any object as if it were a function
Post by Julian Rohrhuber
hello julian,
we seem to have left the initial topic well behind.
but i think there was a conclusion of sorts, ie.
- supercollider functions ignore "extra" arguments, this is not by
accident but design, it allows 'collect' and family to provide
"optional" indices, etc.
- this rule, in combination with default values, and in particular the
default default value of "nil", means that all supercollider
functions allow any number of arguments
- it may be possible to warn about cases where "too many parameters"
are written into the "text", but it's not trivial
getting to the off-topic (but interesting) parts...
Post by Julian Rohrhuber
If the argument definitions are generic enough, this may make sense.
i think we mean the same thing, my idea is precisely that "If the
argument definitions are generic enough" means that the function is
properly a "list processing function" and might just as well be
written that way.
it's "notational" in different way than in c & ml etc. (because
there's no standard notation for heterogenous lists) and for lisp &
scheme etc. (because the notation for heterogenous lists is precisely
a variadic function).
Post by Julian Rohrhuber
Well, I still sense that arity and type are somewhat related, and may be
even treated on the same level - your example seems to support this: it
looks just like pattern matching on type.
again, i think we mean the same thing.
in scheme etc. (and supercollider) multiple arguments _are_ the
"notation" for functions over "product types".
in ml etc., where there is a direction notation for these, it's very
clear that multiple arguments are only a "syntax".
(it's particularly clear when you see that the type of the "primitive"
fixed-precision-integral-adder-with-carry in ghc is "int -> int ->
(int,int)" rather than "(int,int) -> (int,int)".)
(the fifth revision of scheme introduced "multiple return values",
which are the other side of this equation.)
http://people.csail.mit.edu/jaffer/r5rs_8.html#IDX423
Post by Julian Rohrhuber
[1, 2, 3, 4, 5].reduce { |a, b, c| a * b - c };
1 * 2 - 3 =3D> -1
-1 * 4 - 5 =3D> -9
But, if you pass a selector instead of a function, the method's arity
depends on the object it calls. Still, possible, but possibly confusing.
i think so, but then i would... scheme's "fold" does allow the
function to have more than two arguments, but the rule is that then
you need to provide more than one "list", ie.
http://www.r6rs.org/final/html/r6rs-lib/r6rs-lib-Z-H-4.html#node_idx_212
Post by Julian Rohrhuber
Hm, I had suspected that integers are a function that return themselves
or something like that.
i don't think you can define that in ml etc.
Post by Julian Rohrhuber
let f _ = f
<interactive>:8:11: Occurs check: cannot construct the infinite type: t1 ~ t -> t1
you can in scheme & supercollider etc. but what to do with it?
sc3> f = {f};
-> a Function
sc3> f.();
-> a Function
sc3> f.() == f;
Post by Julian Rohrhuber
But that was thinking it too much from a mathematical angle I
suppose.
you can do this, ie. http://en.wikipedia.org/wiki/Church_encoding
but even so (ie. if Integer is encoded as a function) there's still a
distinction between "f : Integer -> Integer" and "g : Integer"
Post by Julian Rohrhuber
Practically, I often wonder if there is could be a way to improve the
situation about polymorphic misunderstanding (or separate between the
good and the bad cases).
i guess f-omega and related are an attempt at that?
http://en.wikipedia.org/wiki/System_F#System_F.CF.89
best,
rohan
_______________________________________________
sc-users mailing list
info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Julian Rohrhuber
2014-10-10 15:48:22 UTC
Permalink
Post by r***@public.gmane.org
hello julian,
we seem to have left the initial topic well behind.
but i think there was a conclusion of sorts, ie.
- supercollider functions ignore "extra" arguments, this is not by
accident but design, it allows 'collect' and family to provide
"optional" indices, etc.
- this rule, in combination with default values, and in particular the
default default value of "nil", means that all supercollider
functions allow any number of arguments
Yes, this is a good way to put it.
Post by r***@public.gmane.org
- it may be possible to warn about cases where "too many parameters"
are written into the "text", but it's not trivial
It is almost trivial, but adds the cost of one integer comparison to *each* method call.

The implementations of blockValue, blockValueEnvir ... and of executeMethod. The valueArray primitive is separate (blockValueArray), so that implicit variable arguments should still work as usual.

I don't know if it is worth the electricity, but it may well be! (opinions?)
Post by r***@public.gmane.org
getting to the off-topic (but interesting) parts...
Post by Julian Rohrhuber
Well, I still sense that arity and type are somewhat related, and may be
even treated on the same level - your example seems to support this: it
looks just like pattern matching on type.
again, i think we mean the same thing.
in scheme etc. (and supercollider) multiple arguments _are_ the
"notation" for functions over "product types".
in ml etc., where there is a direction notation for these, it's very
clear that multiple arguments are only a "syntax".
(it's particularly clear when you see that the type of the "primitive"
fixed-precision-integral-adder-with-carry in ghc is "int -> int ->
(int,int)" rather than "(int,int) -> (int,int)".)
(the fifth revision of scheme introduced "multiple return values",
which are the other side of this equation.)
http://people.csail.mit.edu/jaffer/r5rs_8.html#IDX423
Interesting! If I understand the documentation correctly, in the early Smalltalks, messages were a number of values on the stack, and it was up to the receiver object to "use them up" more or less. The rest of the message could then either be passed on by the receiver for further consumption, or, when it returned control to the caller, the caller could consume the rest (and only the rest) of the message. This was given up in Smalltalk-80 onwards for efficiency and clarity reasons.

"The Smalltalk-76 interpreter assumed that the receiver of a message would be on the top of the execution stack, with arguments below it. The number of arguments was not specified in the "send" instruction, but was determined from the method header after message lookup." (Glen Krasner, 80 bits of history)
Post by r***@public.gmane.org
Post by Julian Rohrhuber
Hm, I had suspected that integers are a function that return themselves
or something like that.
i don't think you can define that in ml etc.
Post by Julian Rohrhuber
let f _ = f
<interactive>:8:11: Occurs check: cannot construct the infinite type: t1 ~ t -> t1
you can in scheme & supercollider etc. but what to do with it?
sc3> f = {f};
-> a Function
sc3> f.();
-> a Function
sc3> f.() == f;
Well, in sclang, you have
2.() == 2
(or for any object by default)
It is useful e.g. when you are taking all values to be generators/streams. James McCartney's generator classes (in the generator Quark) return a copy of themselves for every value - which is something in between.
Post by r***@public.gmane.org
Post by Julian Rohrhuber
But that was thinking it too much from a mathematical angle I
suppose.
you can do this, ie. http://en.wikipedia.org/wiki/Church_encoding
but even so (ie. if Integer is encoded as a function) there's still a
distinction between "f : Integer -> Integer" and "g : Integer"
It is probably more something in theorem provers like Agda.
Post by r***@public.gmane.org
Post by Julian Rohrhuber
Practically, I often wonder if there is could be a way to improve the
situation about polymorphic misunderstanding (or separate between the
good and the bad cases).
i guess f-omega and related are an attempt at that?
http://en.wikipedia.org/wiki/System_F#System_F.CF.89
OK, but I suppose this requires an explicit and static type system first?







_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
r***@public.gmane.org
2014-10-12 00:22:47 UTC
Permalink
Post by Julian Rohrhuber
I don't know if it is worth the electricity, but it may well be!
i don't really know what the "cost" is (proportionally) so can't comment.

but if it's straightfoward, and you make a patch, i'd of course use it...
Post by Julian Rohrhuber
(Glen Krasner, 80 bits of history)
i'll need to read more of that to grasp what you mean, it's a little obscure to me.

the history of "strongtalk" is curious as well, http://www.strongtalk.org/history.html

complex and highly optimised systems have a particular sort of fragility.
Post by Julian Rohrhuber
Well, in sclang, you have 2.() == 2 (or for any object by default)
and of course also 2.value(3,4)==2

i think this is very close to the centre of my confusion, and oddly
enough circles back to the subject.

in other words i don't really grasp why is it that in supercollider we
want 2.(3,4)==2 and in lisp we want (2 3 4)==error.

it seems to have something to do with the relation between the
"ambient" meaning of words (ie. what "value" is "generally understood"
to do) and the way that words are actually used by the "receiver".

i'm reminded of john macfarlane's observation about markdown, "any
string of characters is valid" https://github.com/jgm/cheapskate

"informal formal" languages are super interesting, but there is a
definite tension about how it is that things can go astray.
Post by Julian Rohrhuber
James McCartney's generator classes (in the generator Quark)
again thanks for the reference, i didn't know of this.
Post by Julian Rohrhuber
but I suppose this requires an explicit and static type system first?
i really don't know.

type inferencing is "constructive" in interesting ways that i don't
properly understand. depending on where the "holes" are during type
unification, the type "required" as an output can "determine" the type
of an input.

perhaps it's another "directions" joke, the inverse of "well if i were
going there, i wouldn't start from here".

but it seems that the whole point is that in supercollider we don't
want this kind of rule? i figure that the distinction betwee "value"
at a function and "value" at a number is the sort of thing you mean by
"polymorphic misunderstanding"?

best,
rohan


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Julian Rohrhuber
2014-10-12 20:07:07 UTC
Permalink
Post by r***@public.gmane.org
Post by Julian Rohrhuber
I don't know if it is worth the electricity, but it may well be!
i don't really know what the "cost" is (proportionally) so can't comment.
but if it's straightfoward, and you make a patch, i'd of course use it...
I'll gave it a first try, but for some reason, the changes (even printf) didn't have any effect on the compiled version. Hm, I'll try again later.
Post by r***@public.gmane.org
Post by Julian Rohrhuber
(Glen Krasner, 80 bits of history)
i'll need to read more of that to grasp what you mean, it's a little obscure to me.
the history of "strongtalk" is curious as well, http://www.strongtalk.org/history.html
complex and highly optimised systems have a particular sort of fragility.
Yes, I suppose now with LLVM and all that, it may even easier to just generate c-code. But that paper (http://www.cs.ucsb.edu/~urs/oocsb/papers/pldi94.pdf) is interesting for sure. For sclang it would be most needed to have dynamic compilation to add methods (And perhaps primitives) at runtime without having to rebuild the whole method table. I don't know how difficult that would be.
Post by r***@public.gmane.org
Post by Julian Rohrhuber
Well, in sclang, you have 2.() == 2 (or for any object by default)
and of course also 2.value(3,4)==2
i think this is very close to the centre of my confusion, and oddly
enough circles back to the subject.
in other words i don't really grasp why is it that in supercollider we
want 2.(3,4)==2 and in lisp we want (2 3 4)==error.
That captures it very well, I think.

Some clues:

# In lisp, function evaluation is implicit (x y), while in sclang, it is explicit by method call (x.value(y)). In supercollider, variable assignment is implicit (x = 5), while in lisp it is explicit (define x 5).

# Making the function name explicit, we should compare

the sclang message
value(2, 3, 4)

with the imaginary lisp function
(value 2 3 4)

(which is like the following, I suppose:)
(apply 2 (list 3 4))

So why we want 2 in sclang and error in lisp here? I also don't know exactly where this difference comes from. It could be merely historical.
Post by r***@public.gmane.org
it seems to have something to do with the relation between the
"ambient" meaning of words (ie. what "value" is "generally understood"
to do) and the way that words are actually used by the "receiver".
Yes, each and every object (also a number) is a little interpreter, which is in charge of giving the term "value" a meaning in the first place. This brings every function into the local context of an interpreter with some private state. In other words, what "value" means, depends on the object. There is no "general" or "ambient" understanding, just changing conventions. Not always a good thing, obviously!
Post by r***@public.gmane.org
i'm reminded of john macfarlane's observation about markdown, "any
string of characters is valid" https://github.com/jgm/cheapskate
"informal formal" languages are super interesting, but there is a
definite tension about how it is that things can go astray.
Yes, now this is another story: how much you let a programming language become truly casual. Also there is the problem of message names being ambiguous in the "bad" way, as we have mentioned before (and there is a broad spectrum between good and bad, also of "pollution" of name spaces). With enough discipline, and perhaps also the ability to not care about breaking existing code, OOP systems can be refactored in a really conceptually and formally consistent way. But they (arguably) can't enforce what is consistent, because this has to do with the domain a language attempts to model.
Post by r***@public.gmane.org
Post by Julian Rohrhuber
James McCartney's generator classes (in the generator Quark)
again thanks for the reference, i didn't know of this.
It's a little inefficient, otherwise it would have been a good candidate for both patterns and ugen behaviour, I think.
Post by r***@public.gmane.org
Post by Julian Rohrhuber
but I suppose this requires an explicit and static type system first?
i really don't know.
type inferencing is "constructive" in interesting ways that i don't
properly understand. depending on where the "holes" are during type
unification, the type "required" as an output can "determine" the type
of an input.
perhaps it's another "directions" joke, the inverse of "well if i were
going there, i wouldn't start from here".
but it seems that the whole point is that in supercollider we don't
want this kind of rule?
Indeed it may not make sense to have a type system that is global but an object system that is local. I don't know what languages like Eiffel are doing. But from what I understand about pure object oriented programming, types would need to be defined in the receiver object only: probably by a set of messages certain arguments are supposed to respond to by returning certain other objects which, in turn respond to a set of messages etc.
Post by r***@public.gmane.org
i figure that the distinction betwee "value"
at a function and "value" at a number is the sort of thing you mean by
"polymorphic misunderstanding"?
Exactly, meaning the good one. The bad one may be a class called "Money", which returns its current "value", or a class "Morals", which returns a moral value (such as "justice"). But who is to tell?





_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
r***@public.gmane.org
2014-10-13 03:51:03 UTC
Permalink
hello julian,
Post by Julian Rohrhuber
I'll try again later.
don't waste time on my account, it took me years to even realise this
was happening, so it's hardly urgent.

on the rest, it'll take me a little while to think some of these ideas
Post by Julian Rohrhuber
in other words i don't really grasp why is it that in supercollider we
want 2.(3,4)==2 and in lisp we want (2 3 4)==error.
That captures it very well, I think.
actually i think i completely confused myself by leaving out the
"value" method name. apologies, i've introduced a red herring.

you're correct, it's (value 2 3 4) and if "value" is doing "single
argument dispatch" then of course it doesn't need to look any further
than "2". "operationally" it makes perfect sense, it even helps me
see why the "arity problem" is so "non-local".

(i used to know this better, ie. http://rd.slavepianos.org/t/ssc3)
Post by Julian Rohrhuber
# In lisp, function evaluation is implicit (x y), while in sclang,
it is explicit by method call (x.value(y)).
in lisp the parentheses actually are the application notation. it's
easy not to see this because parentheses are used for grouping and
precedence in so manby contexts, and in lisp they still "work" that
way. in the same way it's easy to miss that "white space" is the
application notation in ml etc.
Post by Julian Rohrhuber
In supercollider, variable assignment is implicit (x = 5), while
in lisp it is explicit (define x 5).
i think this is equal as well, the single letter globals aside you
either write "var x = 5; x = 6" or "(define x 5) (set! x 6)".

(lisps can leave out "define" and just have "set!" with a rule that if
you get to the top of the "environment" without seeing the binding you
introduce one. scheme's "define" is actually very subtle, see
"correct definition of letrec" at
http://community.schemewiki.org/?scheme-faq-macros)
Post by Julian Rohrhuber
with the imaginary lisp function
(value 2 3 4)
(which is like the following, I suppose:)
(apply 2 (list 3 4))
that was my bad translation, but lisp could give "value" the same
meaning as in supercollider, though necessarily as a "library",
ie. ftp://ftp.parc.xerox.com/pub/mops/tiny/tiny-announce.text

it'd do more or less what supercollider does (ie. consult tables).
Post by Julian Rohrhuber
So why we want 2 in sclang and error in lisp here? I also don't know
exactly where this difference comes from. It could be merely historical.
i was wrong, "value" could work the same in lisp. but i think you're
correct that it's a library for historical reasons and perhap also
because it's so much harder than plain lisp to optimise (and is
generally more complicated), so the plain case is kept as as basis.

will reply to other ideas more slowly, and hopefully less erroneously!

my idea that lisp and smalltalk are "the same thing" is obviously
modulo a million subtle variations...

best,
rohan


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

felix
2014-08-27 07:29:19 UTC
Permalink
thisMethod.numArgs
thisMethod.varArgs

the interpreter could check if there are too many args when calling the
method, but that would add a substantial overhead in that it would be on
every single method call.
Post by Julian Rohrhuber
So a warning would (erroneously) imply that this is undesirable behaviour.
A warning would only be posted if varArgs is false
Post by Julian Rohrhuber
There isn’t really a way (that I can think of) for checking the number of
arguments in the SC language. Partly because, some methods and even
functions CAN take any number of arguments, and second, I don’t think the
number of expected arguments is really stored somewhere easily accessible
to the external SC language.
Josh
******************************************
/* Joshua D. Parmenter
http://www.realizedsound.net/josh/
“Every composer – at all times and in all cases – gives his own
interpretation of how modern society is structured: whether actively or
passively, consciously or unconsciously, he makes choices in this regard.
He may be conservative or he may subject himself to continual renewal; or
he may strive for a revolutionary, historical or social palingenesis." -
Luigi Nono
*/
dear list,
what is the rationale for allowing the above?
it can make locating misplaced parenthesis somewhat more obscure than expected?
could it not print a warning?
best,
rd
_______________________________________________
sc-users mailing list
http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
--
..
http://soundcloud.com/crucialfelix
http://github.com/crucialfelix
.
Loading...