Giter VIP home page Giter VIP logo

Comments (7)

JeffBezanson avatar JeffBezanson commented on April 28, 2024

This is the only example of this "dodginess" that I'm aware of. Set union is a different operation than adding an element to the set. add(s, e) should always add e as an element. union(a,b) makes a new set that is the union, and union!(a, b) could add the elements of b to a. Actually we don't allow identifiers with ! but I could change that.

At least, we should write down what the collections interface is, I believe it consists of methods

start, done, next, ref, assign, add, get, has, del, isempty, length

from julia.

StefanKarpinski avatar StefanKarpinski commented on April 28, 2024

Awesome — writing down the interface is an excellent start. If that's the only dodgy API issue, then that's really good and this issue will be much easier to close than I anticipated.

from julia.

JeffBezanson avatar JeffBezanson commented on April 28, 2024

Here's a question: should we use has(a,i) to test whether an array element has been assigned? I suppose has for arrays would work on any integer, and if the index is out of bounds it just returns false. isassigned might require an in-bounds index. Is that useful or should we just use has?

from julia.

StefanKarpinski avatar StefanKarpinski commented on April 28, 2024

That's a tough question. I guess the difference between an unassigned index and an out of bounds index is that you couldn't assign something to an out-of-bounds index even if you tried. What would the corresponding distinction for hashes be? Does using a key of the wrong type cause an "out-of-type" exception? Is that analogous to an out-of-bounds exception?

from julia.

JeffBezanson avatar JeffBezanson commented on April 28, 2024

Possible additions to this interface:

adjoin, find

There are some other questions about how arrays fit the collections interface. I'm using del(a, i) to remove an element from an array, but it's not really the same as deleting from a hash table since the elements get shifted down so there might still be something at that index. Maybe it should be remove(a,i)?

We should take a vote or something on whether to use "x!" identifiers for mutating.

Also note contains in tensor.j and in and index_of in graph.j. These functions are ripe for standardization.

from julia.

JeffBezanson avatar JeffBezanson commented on April 28, 2024

Another one: I'm not sure the method has(String,Char) is right. In all other cases has checks for the presence of a key, not a value.

from julia.

StefanKarpinski avatar StefanKarpinski commented on April 28, 2024

Yeah, I was considering making a spreadsheet of what various languages use for different operators and use that to try to pick the 1) best, 2) least surprising to the largest number of people.

from julia.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.