Julia: rename `isa` to `instanceof`?

Created on 7 Dec 2016  路  16Comments  路  Source: JuliaLang/julia

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

Most helpful comment

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

All 16 comments

Java also has instanceof, though it it used infix.

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

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

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

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

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

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.

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

I find instanceof a bit too long.

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.

I like the fact that most predicates begin with is.

In another context, I used _is_ followed by _a kind of_ in anagram form:

fourtytwo = "42"
isako( fourtytwo, Integer )

I can never remember the name of the isa function.

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

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).

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.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

helgee picture helgee  路  3Comments

StefanKarpinski picture StefanKarpinski  路  3Comments

ararslan picture ararslan  路  3Comments

dpsanders picture dpsanders  路  3Comments

yurivish picture yurivish  路  3Comments