Design for Named (Symbol, Keyword, Tags)
Currently the code have a special treatment for symbols, then Keyword and Tags are a "new type" of Symbol :
case class EDNSymbol(value: String, namespace: Option[String] = None) extends EDNValue {
override def toString = value
}
case class EDNKeyword(value: EDNSymbol) extends EDNValue {
override def toString = s":$value"
}
case class EDNTagged[A](tag: EDNSymbol, value: A) extends EDNValue {
override def toString = s"#$tag ${value.toString}"
}
I would say, the semantic behind is not quite like that, but more like :
case class Named(value: String, namespace: Option[String] = None) {
override def toString = namespace.map(_ + "/" + value).getOrElse(value)
}
case class EDNSymbol (named: Named) extends EDNValue {
override def toString = named
}
case class EDNKeyword(named: Named) extends EDNValue {
override def toString = s":$named"
}
case class EDNTagged[A](tag: Named, value: A) extends EDNValue {
override def toString s"#$named ${value.toString}"
}
It's a bit picky, but one advantage of that is you can write safe implicit conversion from String / Symbol to Named, then simplifying the EDN' AST construction.
EDNKeyword('ahoy) // ...
Good proposition, I had questions about this part of AST anyway... In Datomisca, we had defined it more like that... I will push this update to see how it behaves...
BTW, using the macro, you can create those symbol & keywords directly:
EDN(":myns.foo/bar")
For information :
see #7 btw you can use : https://hub.github.com/hub.1.html and git pull-request -i 5 to transform an issue into a PR.
Yes I know but I was too lazy between celebrations to install hub on my archlinux :D
On Fri, Jan 2, 2015 at 12:36 AM, Jonathan Winandy [email protected] wrote:
For information :
see #7 https://github.com/mandubian/scaledn/pull/7 btw you can use : https://hub.github.com/hub.1.html and git pull-request -i 5 to transform an issue into a PR.
— Reply to this email directly or view it on GitHub https://github.com/mandubian/scaledn/issues/5#issuecomment-68502391.