Probably happy to make ~ an infix operator since that doesn't conflict. Making it syntactic is also possible but more controversial.
While we're on the topic, are there any plans to allow user-defined operators? (E.g., specifying that a certain character sequence is a left-associative binary operator of a given precedence.) These can be very useful to make code more readable, especially if you start doing functional-style programming (e.g., the reverse composition operator '|>' used in F#); you can't expect the language designers to think of all the useful operators in advance.
> Probably happy to make ~ an infix operator since that doesn't conflict.
> Making it syntactic is also possible but more controversial.
Please don't be in a hurry here. Julia has something that R never had
and R users are not accustomed with - macros.
Statistical languages like BUGS should be implemented as a micro
language similarly to Common Lisp loop macro. Formulas are rudimentary,
20 years old constructs, good only for specifying simple, one-line
models.
Many other so praised features of R are old and don't correspond to
current needs anymore. Please don't be in a hurry to get things from R
as they are, especially on expense of modifying the language.
Vitalie.
>>> formulas are great for specifying single equation models but there is nostandard syntax in R for specifying more complicated statistical models.
>>>> Jeff Bezanson <jeff.b...@gmail.com>
>>>> on Fri, 6 Apr 2012 16:43:15 -0400 wrote:
>> Probably happy to make ~ an infix operator since that doesn't conflict.
>> Making it syntactic is also possible but more controversial.
> Please don't be in a hurry here. Julia has something that R never had
> and R users are not accustomed with - macros.
> Statistical languages like BUGS should be implemented as a micro
> language similarly to Common Lisp loop macro. Formulas are rudimentary,
> 20 years old constructs, good only for specifying simple, one-line
> models.
Forgot to mention here that to manipulate formulas programmaticaly is a
hell, as one needs text parsing to construct them.
> Vitalie, can you give an example of how you're thinking about using macros
> to describe statistical models? It's not 100% obvious to me what you mean
> by that. Thanks!
Well, obviously I am not 100% sure either. The main problem in a stat
language is how you cleanly express hierarchy and grouping.
Just to give a visual feeling of a "microlanguage", here is how an
example of a normal hierarchy with heterogeneity across group1 and
group2 might look:
@model with data MYDATA
for vars
a ~ rvNorm mu = 0 sigma = 1 by GROUP1
s ~ rvGamma alpha = 1 beta = 1 by GROUP2
b ~ rvNorm mu = a sigma = s
Y ~ rvNorm mu = b*X sigma = 3
do
fun = s + 3
precision = 1/s
return [a, b, precision, fun]
@end
Which without infix "~" operator in julia might look like:
@model with MYDATA
for a::rvNorm{0,1} by GROUP1
s::rvGamma{alpha, beta} by GROUP2
b::rvNorm{a,s}
Y::rvNorm{b*X}
do begin
fun = d + 3
precision = 1/s
end
return [a, b, precision, fun]
@end
MYDATA contains X, Y, GROUP1, GROUP2. Last two factors in R sense.
The above is sort of vectorized R-ish thinking, something closer to
BUGS syntax might be more appropriate for julia.
Something across these lines I've been trying to get done an year or so
ago for R (https://github.com/vitoshka/pbm). Will resume working on it
pretty soon; still hope to get something out out of the idea.
> On Sat, Apr 7, 2012 at 2:32 AM, Vitalie Spinu <spin...@gmail.com> wrote:
>> >>>> Jeff Bezanson <jeff.b...@gmail.com>
>> >>>> on Fri, 6 Apr 2012 16:43:15 -0400 wrote:
>>
>> > Probably happy to make ~ an infix operator since that doesn't conflict.
>> > Making it syntactic is also possible but more controversial.
>>
>> Please don't be in a hurry here. Julia has something that R never had
>> and R users are not accustomed with - macros.
To be clear, I don't mind an infix ~ operator at all. I am against
giving it the quoting meaning by default (as in R). But this is
apparently also what Jeff meant.
Best,
Vitalie.