Git Product home page Git Product logo

Comments (8)

soc avatar soc commented on May 5, 2024

Incomplete list (feel free to add more):

  • assert: This one is ok and doesn't need to be changed.
  • {Long,Int,Byte}#div: Keep as-is.
  • {Long,Int}#toChar: Migrate to Option?
  • String#{fromBytesPartOrNull,fromStringPartOrNull}: Probably going away.
  • Array#get: Keep as-is.
  • Array#set: Keep as-is.

from dora.

dinfuehr avatar dinfuehr commented on May 5, 2024

Agreed, however I wouldn't change the return type for Array#get and Array#set to Option[T]. Additional methods that return an Option would be great though. At the moment those methods aren't declared throws either, it would just be too much boilerplate for array-heavy code without too much added value (most of the time folks would just write array(idx).unwrap() anyways. Following this logic even operations like a / b would have to return an option to handle div-by-0.

from dora.

soc avatar soc commented on May 5, 2024

I wouldn't change the return type for Array#get and Array#set to Option[T].

My hope would be that we would have a rich enough iterator/collections/streaming API one day, that we would look back on this and say "the alternatives are so good and popular, changing get/set to not throw would have minimal impact".

Also, having the array operations as Option would actually be more regular with other collection's lookup operations like Set#get or Map#get.

But I think we should keep it as-is, because there is still a long way to go before this can even be considered.

At the moment those methods aren't declared throws either, it would just be too much boilerplate for array-heavy code without too much added value [...]

Totally agree!

Following this logic even operations like a / b would have to return an option to handle div-by-0.

Agreed, I have been thinking about this some time ago and how it can be dealt with without introducing lots of boilerplate.

from dora.

dinfuehr avatar dinfuehr commented on May 5, 2024

Agreed, let's revisit this later.

from dora.

soc avatar soc commented on May 5, 2024

I think the remaining ones are easily identified due to the mandatory throws keyword, or are there any other exceptions like for arrays that you can think of?

from dora.

dinfuehr avatar dinfuehr commented on May 5, 2024

None that I remember right now.

from dora.

soc avatar soc commented on May 5, 2024

Great, thanks!

from dora.

soc avatar soc commented on May 5, 2024

I documented the existing (assumed public-facing) cases, I think this can be closed for now.

panics

from dora.

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.