Discussion about namespaces
shalabhc opened this issue · comments
Does include
do a text inclusion and is there only one global namespace for all function names? Is there a way to namespace the functions and types? If not, is there a plan to add these?
Yes, it is mostly text inclusion, and there are no namespaces. Lobster has grown from a much simpler language, and it just never happened, but it should.
There is the private
keyword which removes a function/struct/variable from the global namespace, and makes it only available to the current file. This was I guess the simplest thing to make things workable without namespaces :)
builtin functions tend to use explicit identifier namespacing, e.g. gl_
.
Haven't spent much time thinking what namespaces should look like if they are added. Not a fan of ::
since it is "loud", or "." since it makes it look the same as dereferencing. I like _
, but that clashes with its existing use in identifiers.
I guess include/gui.lobster
is a good example of how currently a library is written with an explicit namespace and private
. It be easy to add a namespace gui
declaration that would achieve the same thing without having to explicitly prepend gui_
to all public functions in that file. Or it could use something other than .
, but that would require changes in all users.
Lobster has namespaces nowadays :) See namespace
in http://aardappel.github.io/lobster/language_reference.html