Language: import accepts optional list of imported symbols - #551
Conversation
e4083b0 to
70c78b4
Compare
|
I'm playing around with this. Some observations:
I'm not sure if I like the {} notation. I'm playing around with symbols: I like the [] and () also, except for the traling semi-colon.... For implementation, I expected that you used the InitListExpr to store the import-list. I think your version is a bit more compact in memory (as it is tail-allocated). We will need to update the refs plugin for this, so can a ref for 'printf' is generated. |
|
Wow this is getting fancy... The u32 ImportDecl.symlist_count causes the ImportDecl to grow by 8 bytes. In Decl there are still 17 bits in the flags left. That would easily fit any list a user could add. Then the size would remain 40 bytes :) |
d137064 to
7d8064a
Compare
Good point, actually only 16 bits left in the |
* this helps readability and reduces symbol table lookups
* syntax is `import stdio { fopen, fclose, printf }`
* `import module local;` is now `import module { * }`
* explicitly imported symbols can be aliased:
`import stdio { malloc as alloc }`
import stdio { fopen, fclose, printf }