Home Demos Forum Research Guide
Viewing topic in forum 'general'
back to topic list

Extending the scope data type definition
I have seen examples and codes in the central source tree where new data types are declared alongside interface or component declarations. These data types are only avaliable to other components that provides or requires the interface. Is it possible to declare datatype in such a way that any component or interface that are available or declare in advance to be able to use them?
by enesi on 2015-06-02 13:44:06 (1 reply)


We often declare data types with interfaces when we think they're likely to only be used alongside that interface. However, if you're not requiring or providing an interface, you can always include all of the types defined in a particular source file with the "uses" notation as follows:

uses File;

Where "File" can be a package path, for example:

uses time.DateTime;

With the above notation, the Dana compiler will search for a Dana source file which matches this package name and path, for example "resources/time/DateTime.dn" in the above example. All type definitions from this file are then available for use.

One example of this is in esher.dn, which "uses" the Service interface because it neither provides nor requires it, but does need to be able to use that type as part of its behaviour.

I realise this is not actually documented at the moment, so we'll update the documentation soon.

Hope that all makes sense - let me know if not.

- Barry
by barry on 2015-06-02 14:29:39
© Francis Research Ltd. 2017