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

Undefined operator "<-" and -2 < -1 #3270

Closed
bsxfan opened this issue Jun 2, 2013 · 4 comments
Closed

Undefined operator "<-" and -2 < -1 #3270

bsxfan opened this issue Jun 2, 2013 · 4 comments
Labels
needs decision A decision on this change is needed

Comments

@bsxfan
Copy link

bsxfan commented Jun 2, 2013

This comparison fails unexpectedly:

julia> -2<-1
ERROR: <- not defined

So it seems that <- is parsed as an as yet unused operator. One way to have your cake and eat it, is to define:

(<-)(x,y) = <(x,-y)

which will make -2<-1 work as expected, and still leave <- available as a new user-defined operator.

Are there plans to use <- for something in future?

And by the way, are there any plans to make available any other new user-defined operators?

@pao
Copy link
Member

pao commented Jun 2, 2013

Parsing of <- is currently exploited by Monads.jl. I am not aware of other uses.

@diegozea
Copy link
Contributor

diegozea commented Jun 2, 2013

Isn't used on base/

grep "<-" ~/bin/julia-master/base/*.jl
/home/dzea/bin/julia-master/base/bitarray.jl:# shorthand forms BitArray <-> Array

But is in src/ :

grep "<-" ~/bin/julia-master/src/*
/home/dzea/bin/julia-master/src/julia_flisp.boot:                    |\|\|| && <- -- --> > < >= <= == === != !== .> .< .>= .<=
/home/dzea/bin/julia-master/src/julia_flisp.boot:                      #7=(<- -- -->) #10=(> < >= <= == === != !== .> .< .>=
/home/dzea/bin/julia-master/src/julia-parser.scm:     (<- -- -->)

@JeffBezanson
Copy link
Sponsor Member

I wanted to leave various operators around for custom use, but my first reaction here is to remove this. An expression like x<-y is too basic to interfere with.

@pao
Copy link
Member

pao commented Jun 2, 2013

I know we already lost a couple arrowlike operators (#1267); it'd be nice to have some alternative if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs decision A decision on this change is needed
Projects
None yet
Development

No branches or pull requests

4 participants