Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow x[i,j;k] syntax to be parsed #7225

Closed
mlubin opened this issue Jun 11, 2014 · 12 comments
Closed

allow x[i,j;k] syntax to be parsed #7225

mlubin opened this issue Jun 11, 2014 · 12 comments

Comments

@mlubin
Copy link
Member

mlubin commented Jun 11, 2014

In JuMP, it would be convenient if we could use the syntax x[i,j;k] within macros. We already take advantage of x{i,j;k}. Any reason not to allow this syntax and make it a compile-time error when used in code instead of a parser error? @IainNZ @joehuchette

@StefanKarpinski
Copy link
Member

What should it mean?

@joehuchette
Copy link
Member

In JuMP we would use it to add conditionals when creating variables, e.g.

@defVar(m, x[i=1:n, j=1:n; i < j])

So for our purposes we only want that it's valid syntax so we can parse it in a macro.

@mlubin
Copy link
Member Author

mlubin commented Jun 11, 2014

It shouldn't mean anything in Julia, but it should be parsed as

Expr(:ref, :x, Expr(:parameters,:k),:i,:j)

This is analogous to x{i,j;k} which is parsed as

Expr(:curly, :x, Expr(:parameters,:k),:i,:j)

and x(i,j;k) which is parsed as

Expr(:call, :x, Expr(:parameters,:k),:i,:j)

@stevengj
Copy link
Member

It makes sense to me that getindex should be able to take keyword arguments, which is essentially what this is. i.e. a[args...] should be parsed exactly as getindex(a, args...), including ; and keywords.

@StefanKarpinski
Copy link
Member

True, but we had discussed using the v[i;j] syntax at some point.

@mlubin
Copy link
Member Author

mlubin commented Jun 12, 2014

If it is used, it will need to be parseable anyway. The meaning of the syntax in Julia doesn't need to be decided here.

@stevengj
Copy link
Member

@StefanKarpinski, when was that? What was the proposed meaning? Was that before we had keyword args?

@StefanKarpinski
Copy link
Member

It was for "contravariant indexing" – the idea was that v[i;j] would drop leading singleton dimensions instead of trailing singleton dimensions. The idea never went anywhere though.

@mlubin
Copy link
Member Author

mlubin commented Jun 18, 2014

@StefanKarpinski, any objections to this?

@StefanKarpinski
Copy link
Member

No, I'm ok with it, but it would be good to check with @JeffBezanson – surface syntax is his baby.

@mlubin
Copy link
Member Author

mlubin commented Aug 24, 2014

Bump now that 0.4 is open.

@jakebolewski
Copy link
Member

closed by #8250

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants