GithubHelp home page GithubHelp logo

No need for $. about dollar HOT 8 CLOSED

ankurp avatar ankurp commented on July 19, 2024
No need for $.

from dollar.

Comments (8)

ankurp avatar ankurp commented on July 19, 2024

Are you suggesting creating categories like in Objective-C for array, dictionary, etc. types in Swift?

from dollar.

ankurp avatar ankurp commented on July 19, 2024

Based on some interest I'm thinking it might be worth creating another project within this repo which would shared functionality and implement extensions for different collection types.

Developer would then have a choice to import a pure functional library like Dollar or import extensions via Cent library.

from dollar.

nubbel avatar nubbel commented on July 19, 2024

I think what @eklipse2k8 meant is that we don't need a class to namespace the functions, because they are implicitly namespaced by the framework's module, i.e. "Dollar". So even without having the functions grouped under a class a third party app can call them like Dollar.first([1,2]) (or just first([1,2])) but not $.first([1,2]).

from dollar.

eklipse2k8 avatar eklipse2k8 commented on July 19, 2024

@nubbel exactly. These are handy functions that you could even make some of them generics, without needing to type $.

from dollar.

ankurp avatar ankurp commented on July 19, 2024

@eklipse2k8 and @nubbel I see what you guys mean but to avoid ambiguity and not to pollute the namespace of the class in which it is being used it would be good to have a namespace to reference these functions by. So for example calling a function as Dollar.first imply that it is the library function and not the Swift.first which can also be implemented in the future as part of language update or another first function defined in the class. The compiler sometimes complains with Ambiguous use of 'first' as seen here if there are duplicate function names

screen shot 2014-06-28 at 7 36 09 pm

I created a new project in the repo that creates extensions using the functional version in this branch https://github.com/ankurp/Dollar.swift/pull/59/files#diff-ca1a7525d799b7ad848ca0362a4dd934R9

So now you can import Cent if you want extension version or import Dollar if you want to import a functional version of the library. I need to add more functions and classes before I merge this.

from dollar.

nubbel avatar nubbel commented on July 19, 2024

I would prefer generic functions over extensions.

from dollar.

ankurp avatar ankurp commented on July 19, 2024

@nubbel That is why I am keeping Dollar a separate project and framework and Cent is just an extension library using the generic functions from Dollar framework to define the extensions.

from dollar.

alsotang avatar alsotang commented on July 19, 2024

namespace is very important, just keep use $ and dont pollute global

from dollar.

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.