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

rename isa to instanceof? #19524

Closed
StefanKarpinski opened this issue Dec 7, 2016 · 16 comments
Closed

rename isa to instanceof? #19524

StefanKarpinski opened this issue Dec 7, 2016 · 16 comments

Comments

@StefanKarpinski
Copy link
Member

It should be more familiar to Python programmers and potentially less confusing?

@quinnj
Copy link
Member

quinnj commented Dec 7, 2016

Java also has instanceof, though it it used infix.

@KristofferC
Copy link
Member

Instance sounds more like it is related to classes to me. Personally I like isa.

@yuyichao
Copy link
Contributor

yuyichao commented Dec 7, 2016

Would be isinstance for python. What's the confusion about the current one? (especially since is is deprecated now)

@StefanKarpinski
Copy link
Member Author

Just witnessed a room full of confusion about what isa meant, so I thought I'd throw it out there.

@ararslan
Copy link
Member

ararslan commented Dec 7, 2016

Do you know what about it they found confusing? It's always seemed quite clear to me.

@johnmyleswhite
Copy link
Member

I think people often confuse isa with <:. I've done it myself a bunch of times.

@StefanKarpinski
Copy link
Member Author

Deprecation of is definitely helps. Maybe it's just fine; people do seem to confuse it with <:. I'm not sure what the solution is. I think that :: and <: are fairly clear (although sometimes those get confused too). Maybe there's nothing to be done here.

@yuyichao
Copy link
Contributor

yuyichao commented Dec 7, 2016

What I do want from time to time is an operator for isa.

@JeffBezanson
Copy link
Member

I find instanceof a bit too long.

@pabloferz
Copy link
Contributor

pabloferz commented Dec 7, 2016

If isa were also an operator (as in is, for example), that probably would help to avoid for some people to get confused, with the benefit of being easy to type. E.g.

a = 1
if a isa Int
    #do something
end

which, seems pretty clear to me.

@simonbyrne
Copy link
Contributor

I like the fact that most predicates begin with is.

@JeffreySarnoff
Copy link
Contributor

In another context, I used is followed by a kind of in anagram form:

fourtytwo = "42"
isako( fourtytwo, Integer )

@oxinabox
Copy link
Contributor

oxinabox commented Dec 9, 2016

I can never remember the name of the isa function.

I tend to write: foo |> typeof <: Integer
which is I guess pseudo-infix.

@iamed2
Copy link
Contributor

iamed2 commented Dec 12, 2016

Just witnessed a room full of confusion about what isa meant, so I thought I'd throw it out there.

Was the confusion about the behaviour or just how to read the function name? I wouldn't mind a change to is_a (a few people at Invenia dislike the "underscore case except sometimes not" rule).

@StefanKarpinski
Copy link
Member Author

I dunno. Probably not worth changing. I agree that the underscore rule can be annoying. @JeffBezanson hates underscores :P. I would be ok with using underscores and then just trying to delete all names that have them in Base over time.

@ararslan
Copy link
Member

I've implemented the infix operator version of isa in #19677, as discussed here by Yichao and Pablo, if anyone's interested in taking a look.

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