# New BASIC Feature “`dim var as new string`”

The introduction of polymorphic struct types into UNO (see Increasing UNO Ease of Use) has lead to the addition of a new feature to BASIC (on SRC680 CWS sb18).

The existing feature “`dim var as new type`”, where `type` is the name of a UNO struct type (see UNO Type System), can be used to create in BASIC instances of UNO struct types. This syntax only works for plain UNO struct types, though. To also support the new instantiated polymorphic UNO struct types, `type` can now be replaced with a string literal that gives the UNO name of an arbitrary UNO struct type. Examples:

`rem` new syntax for instantiated polymorphic struct types:
`dim x as new "com.sun.star.beans.Optional<long>"`
`rem` (circuitous) new syntax for plain struct types:
`dim y as new "com.sun.star.beans.PropertyValue"`
`rem` old syntax for plain struct types:
`dim z as new com.sun.star.beans.PropertyValue`

One problem for BASIC programmers might be that such a string literal has to be a UNO type name, which is rather unrelated to a BASIC type name. For example, the `com.sun.star.beans.Optional` type instantiated over UNO's `short` type (an integral type corresponding to BASIC's `integer`) has to be named `"com.sun.star.beans.Optional<short>"`, not `"com.sun.star.beans.Optional<integer>"`.

The main need to operate on instantiated polymorphic UNO struct types in BASIC will arise once designers of UNO APIs start to use the new features of extended interface type attributes, which leverage the three new polymorphic UNO struct type templates `com.sun.star.beans.Ambigious`, `com.sun.star.beans.Defaulted`, and `com.sun.star.beans.Optional`. (If it turns out then that this new syntax is too awkward to use for the average BASIC programmer, it might be extended.)