Giter VIP home page Giter VIP logo

Comments (6)

quintesse avatar quintesse commented on August 16, 2024

Out of curiosity: why?

from ceylon-sdk.

ikasiuk avatar ikasiuk commented on August 16, 2024

For instance I'd like to be able to use addAll to add the elements of some other List or Iterable to my MutableList by writing lst1.addAll(lst2). If the parameter type is Element... then I have to write something like lst1.addAll(lst2.sequence...) or for (e in lst2) { lst1.add(e); }. On the other hand I can easily change lst1.addAll(1, 2, 3) to lst1.addAll{1, 2, 3}. So I guess parameter type Iterable is preferable here.

from ceylon-sdk.

quintesse avatar quintesse commented on August 16, 2024

Ok understood... although this makes me wonder if this is not something you want in most cases anyway. I mean what's the advantage of having variadic parameters now? Are there examples where you'd want them where passing an Iterable or List just doesn't make sense?

from ceylon-sdk.

ikasiuk avatar ikasiuk commented on August 16, 2024

Citing from @gavinking's comment ceylon/ceylon-spec#488 (comment) :

Sequenced parameters are now a much more special-purpose thing for cases where you don't expect to ever be receiving collections. Things like log(), format(), assertTrue(), etc.

from ceylon-sdk.

gavinking avatar gavinking commented on August 16, 2024

FTR there's a further (slightly obscure) case where sequenced parameters are useful: when you want to write a single method that can masquerade as a T(X), T(X,X), T(X,X,X), etc. This is a bit like JavaScript's arguments array.

I think this will turn out to be very nice for some metaprogramming scenarios. For example, it seems to be a nice way to write interceptors.

from ceylon-sdk.

FroMage avatar FroMage commented on August 16, 2024

Done.

from ceylon-sdk.

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.