About #library, #source, #import and the Dart editor

395 views
Skip to first unread message

Gen

unread,
Feb 28, 2012, 5:10:04 AM2/28/12
to General Dart Discussion
Hi,

yesterday I have tried to find some information about #library,
#source, #import and the Dart editor.
Now here is what I have learned:


#library
----------
1)
Indicates a source file to be used as a library.

The name given as in:
#library("name");
is without importance for the compiler.
But the Dart Editor uses these names for the Tools/Libraries view.

2)
If no #library declaration is given in the file with the "main"
function,
the compiler will add implicitly:
#library("filename");

3)
Only one "main" function per program (and library) is allowed.


#source
-----------
This links a single file.
Linking happens by using a file path as in:
#source("path/of/xxx.dart");

You can link a file with a #library declaration only via #import.


#import
-----------
This links a file and its linked files.
Linking happens by using a file path as in:
#import("path/of/xxx.dart");
or
#import("path/of/xxx.dart", prefix: "somePrefix");

You can link a file with a #library declaration only via #import.


Dart editor: Tools/Libraries view
---------------------------------------------
1)
The Libraries folder structure corresponds to the #import structure
but not the folder structure of the file system.

2)
The Libraries folder names correspond to the names given in the
#library("name")
declarations.

Gen

unread,
Feb 28, 2012, 5:16:58 AM2/28/12
to General Dart Discussion
#import
-----------
You can only link a file with a #library declaration.

A Matías Quezada

unread,
Feb 28, 2012, 5:34:24 AM2/28/12
to Gen, General Dart Discussion
Hi,

After saw this post, I decided we need a wiki to store this type of information, maybe you can copy this here, I remember when I started at dart it was one of the more difficults things to understand when to use #source, and #import and #include.


---
A. Matías Quezada

2012/2/28 Gen <gp78...@gmail.com>
Reply all
Reply to author
Forward
0 new messages