Giter Site home page Giter Site logo

Comments (5)

pocorall avatar pocorall commented on June 2, 2024

As I know, namespace is good when the programmer has a preference to some package name. For example, my.project.name.R is much more frequently used than android.R. Then import my.project.name._ and write just R. However, Scaloid aimed to gradually improve the legacy Android code. Therefore the same class names from different namespaces are both intensively used. For example, android.widget.Button and org.scaloid.common.Button are in this case, if Scaloid does not use $. The code might already imported android.widget._, so Scaloid button should be accessed as common.Button. This is wordy. Someone may suggest that Scaloid can introduce a shorter namespace such as S.Button. Then, why not $Button? It is the shortest as possible.

However, I am not insisting on this. I want to listen about what other people think about prefixing. Please let me know if you have any other idea.

from scaloid.

ramn avatar ramn commented on June 2, 2024

In scala, it is simple to rename stuff on import, for instance: import scaloid.common.{Button => SButton}

I cite Programming in Scala (by Martin Odersky himself), section 6.10:
"Identifiers in user programs should not contain '$' character, even though it will compile; if they do this might lead to name clashes with identifiers generated by Scala compiler."

The dollar sign is used for name mangling by the Scala compiler.

from scaloid.

pocorall avatar pocorall commented on June 2, 2024

Thank you for a citation about $. I haven't thought about it. If it is not permitted in user codes, I suggest a prefix S instead of $.

Although Scala supports renaming on import, it is not advised by IDE and no way of batch renaming multiple classes.

from scaloid.

ramn avatar ramn commented on June 2, 2024

An 'S' prefix seems like a good idea!

from scaloid.

pocorall avatar pocorall commented on June 2, 2024

OK. I changed the prefix to 'S' now.

from scaloid.

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.