-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add imports #314
base: main
Are you sure you want to change the base?
Add imports #314
Conversation
Hey, this is great - I love the idea, and the syntax. BUT... at a glance, the way it's implemented here, it looks like Satriani won't work in web browsers any more, which is kind of a deal breaker; you're importing Rockstar has to run in a browser so that people can try it out on their phone, right there and then, without having to download anything or install nodeJS - that's kinda part of the joke about how anybody can become a "rockstar programmer" (and also how I give out Rockstar stickers when I'm doing talks about it!) How easy would it be to move all the code that handles filesystem interactions into the What do you think? |
Thank you for this comment. Indeed I forgot the web-browser use case! Now, the presence of missing dependencies is checked. I suppose that the day we give an official support to a Rockstar Standard Library it will be nice to provide those standard library files beside the language implementation. That day, doing |
To add another aspect to @dylanbeattie 's point of view: if we create an import feature, it will bind it to NodeJS. It will not be possible to mimic the same behavior in Java, for example. Thus it would close the path for Rocky to be 100% Rockstar compatible. To be 100% platform-independent and 100% browser-compatible, I also recommend to have a common lib. Maybe it's worth to add packages as well - e.g. with the following syntax: |
I'm not sure to get your point. The
Sure, that's another big topic that would require a dedicated discussion to define a 'Standard Library' for Rockstar.
Yes, I hesitated on this point to specify or not how includes should work, like:
Notice the door is also opened for namespaces and other OOM concepts. |
OK, I got it, I misunderstood first. It's OK - actually Rocky already supports it, except the aliasing feature.
Agree. The standard library may be a dedicated Git repo, where anybody can contribute.
If we are using standard library, the path should be the absolute path within the library. For browser-only compatibility this is the only option. For command line, we could allow local overrides (relative to working directory, a well-known subdirectory or even relative to a specified folder given as command line parameter). I had the same dilemma while implementing it for Rocky, I think all of them are supported.
Discussions are welcome. I also made proposals, and - just for my fun - implemented an OOP in Rocky. It's my concept, maybe others would do it differently, maybe worth to have a look. I'm ready to follow the defined standard in Rocky once we decide about it. |
If I'm correct, the follow-ups of this discussions are these 5 points:
We can open or link existing issues to these points. |
This change is adding a new dimension to the Rockstar language by allowing rock file imports.
It's based on the issue #56 (and issue #63). Resolves #56, resolves #63
As a side effect it also introduces system variables with the
thy
prefix.I hope you will like this contribution.
Feel free to challenge it!
Here is a short extract of the new specification:
Imports
You can import a rock file in a line statement.
Importing a file will execute its content and populate the local environment with all its symbols (variables, functions).
This will override any previously defined symbols with the same names in the same scope.
Multiple libraries and/or symbols are separated with one of the following:
,
&
, and
'n'
.Featuring [ SYMBOL [ aka NAME ] from ] LIBRARY
Welcome to
,Quoting
,Give a hand for
,Contains a sample of
as
,by
of
,courtesy of
System variables are like common variables but with the special prefix
thy
. System variables won't be imported by theimport
statement.thy Name
isnobody
(ie. empty string) when the script is directly executed; while it's the name of the current file, in lower case and without the .rock file extension, when it's imported.thy Location
is the absolute file name of the current script. It's used internally to find other imported files.