Aladdin - Scala Bugtracking
[#47] project: specification priority: low category: missing feature
submitter assigned to status date submitted
Burak Martin open 2003-06-27 12:24:12.0
subject Constr( T* ) not 1st class
code
// this is not possible

MySuperXML_Tag( children: Elem* ) extends Elem;

factory = new HashMap( String, Elem* => Elem )
factory.put("MySuperXML_Tag", MySuperXML_Tag )
//                            ^
// error "methods with repeated args have to be
//        fully applied"
what happened
if you have a constructor with "repeated parameters", then it is not possible to use the constructor as a value,\
 like above.
The dtd-import tool + parser interface critically depend on 1st class constructors, because you decide
on runtime, which class to construct.
what expected To be able to use MySuperXML_Tag as if it was a constructor My...( children:Seq[Elem] )
[back to overview]
Changes of this bug report
Matthias  edited on  2003-06-27 12:24:12.0
I have the strong feeling that currently, classes with such constructors can only be used in a very limited form. In particular, you can only construct objects of such classes if you statically know all the elements you want to pass to the constructor. If you just have a variable that contains the elements, you are out of luck... Maybe we should rethink what we want to achieve with such classes.
Martin  edited on  2003-07-10 15:43:00.0
Burak  edited on  2003-09-23 18:30:32.0
Lex  edited on  2006-03-28 14:02:44.0
Here's a cleaned up version of the proposal:
import scala.collection.mutable.HashMap

object Test {
case class MySuperXML_Tag( children: Any* )

val factory = new HashMap[String, Any* => Any ]
factory("MySuperXML_Tag") = MySuperXML_Tag
}

It still is not implemented. Additionally, it is not allowed to change the HashMap to use Seq[Any], either:

val factory = new HashMap[String, Seq[Any] => Any ]

It strikes me that it would be nice to have some way to refer to MySuperXML_Tag as a value.... Either * types should be allowed in functions, or there should be a conversion available from embedded * types to Seq types.