import - Why does the Scala API have two strategies for organizing types? -


I have noticed that Scala standard library uses two different strategies for organizing classes, traits and single objects. .

  1. Using those packages whose members are imported, for example, how you get access to scala.collection.mutable.ListBuffer This technique is familiar with Java, Python, etc.

  2. Using the members of the type of properties For example, how does this get you access to the parser type? You first need to mix in scala.util.parsing.combinator.Parsers . This technique is not familiar with Java, Python, etc., and is not used much in third party libraries.

    I think that (2) has an advantage that it organizes both methods and types, but Scala 2.8 can be done by using light (1) in objects of objects is. Why are both strategies?

    The note here is . This option is number 2 which you talk about, and I will only talk about it. Unless you solve the problem by this, you should always take the option number 1.

    Do you miss that Parser class parser class really, parser class depends on itself that < Code> Input is defined on parser :

      Abstract class parser [+ T] extended (input => parscult [t] )   

    type input is defined as:

      type input = reader [alam]   

    and Elem is an example, for example, RegexParsers and TokenParsers and Four. Defines the pre eel as the four , while later it defines it as the token . This means that the parser is different for each, more importantly, because Parser is the subclass of

    parser But you will ensure that when you RegexParsers parser to token parser or vice versa As a matter of fact, you will not be able to pass parser near another example of RegexParsers .

Comments