Feed aggregator

Scala - what is the right way to organize singleton objects hierarchy?

scala on stackoverflow - 27 min 45 sec ago

Here is something that I have came across in Scala that did not cause any problems in Java. Now I just do not know what is the right way of doing this in Scala.

Problem description: I have a Scala Object which denotes an 'abstract' object. It is intended to have a singletonic profile but it is not intended for real use, it is just a bunch of definitions common to it's children-singletons. So instead, I want to use it's children. So there comes the question: since I cannot inherit objects, should the common singleton functionality be realized as a class? As an abstract class? Trait does not suit me because it can't have constructors. If an abstract parent class would do, then how should I access it's singleton (or static) methods if I need them anythere? I realize that there might be a flaw in my design, but since I have this question and can't think of any definitive answer, it is interesting to hear what you say (including design alternatives).

Language parser. Subroutines/Functions processing

scala on stackoverflow - 1 hour 2 min ago

It is my example of subroutines parsing. Does it correct way to do it? subrReserved is a list of subroutine names which are added to lexical.reserved.

abstract class Subroutine case class UserDefinedSubroutine(name: String, args: Option[List[Expression]]) extends Subroutine case class CDDSubr(args: Option[List[Expression]]) extends Subroutine case class CDTSubr(args: Option[List[Expression]]) extends Subroutine case class CFQSubr(args: Option[List[Expression]]) extends Subroutine case class DIETER_DATESubr(args: Option[List[Expression]]) extends Subroutine case class JULDATESubr(args: Option[List[Expression]]) extends Subroutine ... abstract class Statement case class Call(subr: Subroutine) extends Statement def getSubroutineByName(name: String, args: Option[List[Expression]]): Subroutine = name match { case "CDD" => CDDSubr(args) case "CDT" => CDTSubr(args) case "CFQ" => CFQSubr(args) case "DIETER.DATE" => DIETER_DATESubr(args) case "JULDATE" => JULDATESubr(args) ... case _ => UserDefinedSubroutine(name, args) } def callStmt: Parser[Statement] = "CALL" ~> subroutine ^^ Call def subroutine: Parser[Subroutine] = subroutineName ~ opt(argumentList) ^^ { case name~args => getSubroutineByName(name, args) } def subroutineName: Parser[String] = ( elem("subroutine name", subrname => (if (subrReserved contains subrname.chars) true else false )) ^^ (_.chars) | ident)

This week in #Scala (03/02/2012): Scalaxb, Specs2 Spring, Styla and Less-sbt http://t.co/VusXqx5w

#scala on Twitter - 2 hours 8 min ago
This week in #Scala (03/02/2012): Scalaxb, Specs2 Spring, Styla and Less-sbt http://t.co/VusXqx5w

Der @wookieetreiber twittert noch übers Web. Mal schauen, wie lang es dauert bis er sich nen eigennen Client in #scala coded.

#scala on Twitter - 2 hours 9 min ago
Der @wookieetreiber twittert noch übers Web. Mal schauen, wie lang es dauert bis er sich nen eigennen Client in #scala coded.

RT @BinaryJunkie: If you're using #Scala at work tell me if you'd consider going back to Java and if so why, please RT :)

#scala on Twitter - 2 hours 30 min ago
RT @BinaryJunkie: If you're using #Scala at work tell me if you'd consider going back to Java and if so why, please RT :)

working on a #scala #chess game!

#scala on Twitter - 2 hours 59 min ago
working on a #scala #chess game!
Syndicate content