alashworth / test-issue-import

0 stars 0 forks source link

multiple variable declarations on one line #48

Open alashworth opened 5 years ago

alashworth commented 5 years ago

Issue by tpapp Thursday Nov 20, 2014 at 16:47 GMT Originally opened as https://github.com/stan-dev/stan/issues/1145


Would it be possible to allow multiple declarations on one line, that avoid repeating the var_decl part of the grammar? Eg

real alpha, beta, gamma[5];
real<lower=0> a, b[3, 4];

that would be equivalent to

real alpha;
real beta;
real gamma[5];
real<lower=0> a;
real<lower=0> b[3, 4];

and similarly for other types.

This would allow more compact code, could factor out common parts. As far as I understand, this would only change the surface syntax (parser) a bit, and would require no change to the internals.

alashworth commented 5 years ago

Comment by bob-carpenter Thursday Nov 20, 2014 at 18:38 GMT


Thanks for creating the issue.

It's been on our to-do list from the get go, but never got transferred to an issue.

There are two related features, both of which also need issues:

  1. Allowing compound declaration and assignment where relevant (transformed data, transformed parameters, generated quantities, local variables, e.g.,
real alpha <- 1;
  1. Allowing inline local variable declarations, like in C++, e.g.,
beta <- 2;
real alpha;  // local variable declaration
alpha <- 3;  

On Nov 20, 2014, at 11:47 AM, tpapp notifications@github.com wrote:

Would it be possible to allow multiple declarations on one line, that avoid repeating the var_decl part of the grammar? Eg

real alpha, beta, gamma[5]; real a, b[3, 4];

that would be equivalent to

real alpha; real beta; real gamma[5]; real a; real b[3, 4];

and similarly for other types.

This would allow more compact code, could factor out common parts. As far as I understand, this would only change the surface syntax (parser) a bit, and would require no change to the internals.

— Reply to this email directly or view it on GitHub.