Skip to content
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

Imports #58

Open
alexispurslane opened this issue Dec 24, 2014 · 6 comments
Open

Imports #58

alexispurslane opened this issue Dec 24, 2014 · 6 comments

Comments

@alexispurslane
Copy link

I am currently working on a package manager, and the next part, actually making it so that when you install a package, it goes into the include/import/require scope for streem. But we haven't even specified how that should work yet. I was wondering if anyone has any ideas?
My idea looks something like this:

import("package")
# and then, package.blah

It wouldn't be that hard to implement that once we have objects of some kind. Just use the interpreter to eval that file before the rest of the code is executed. And the assign the anonymous class that executing the file returns to the name of the file. I implemented a toy language called Bike in ruby that did it that way.

@naturalethic
Copy link

I like how npm does it, but can't stand that hideous node_modules directory sitting in my pristine project folder. So perhaps placing packages in a .streem folder in the project folder.

@nickmccurdy
Copy link
Contributor

@ChristopherDumas This sounds great, I'm a fan of having actual functions that do imports. I like how you assign packages to variables manually in Node, but this could work well for Streem even if import() just added things to the global (or file) scope.

@naturalethic Agreed. While I don't dislike node_modules, I think .streem would be better for Streem. While you might have to manually access files in node_modules for a Node app for client side stuff, I doubt this would be necessary for Streem (especially since if you were writing a web app, you could just use another package manager like Bower for your client side assets).

@alexispurslane
Copy link
Author

Also, if we made global scope an object, similar to javascript or lua (_G) then import() could be an actual function that used the name as the filename and the identifier name, exactly like i said erliar, except as a function!

@naturalethic
Copy link

I frequently mess around in node_modules when I'm hacking on contribs, so that's not my point really. Anything not going in the git repo should be hidden from my directory listing. bower_components annoys me too. What if the .git folder was git_repository .. fugly right.

@nickmccurdy
Copy link
Contributor

@ChristopherDumas Hmm, sounds like an interesting idea.

@alexispurslane
Copy link
Author

Like I said, I've written a small language similar to scala/python in ruby. That's basically how I wrote imports. Have a function exposed by the runtime to run other files, and then make sure the other files return an object, which is then assigned to the filename, without the extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants