hikari-no-yume / Firth

Firth is a functional, strongly dynamically-typed, concatenative stack-oriented programming language.
Other
29 stars 2 forks source link

Including other files or packages #30

Open raoulvdberge opened 9 years ago

raoulvdberge commented 9 years ago

Will Firth support the including of other files? How will packages (for example, a database package) be imported?

I think this is something to be thought about.

hikari-no-yume commented 9 years ago

I want to have some sort of module system with explicit exports, I think. But as to how that'll work, I don't know yet.

mathroc commented 9 years ago

I was thinking about that too lately, I think it would be ease to build a module system using #18 . a module would just put a record on its stack , eg:

math.firth:

[/sin sin /cos cos /tan tan /pi pi] record.

and we could import it with something like:

/math 'math' import. def.

the import function might execute the file on a new stack (to prevent the module from messing with the existing stack) and a new scope (to avoid having module that suppose that some other modules are already loaded)

raoulvdberge commented 9 years ago

What does record do?

mathroc commented 9 years ago

it's some kind of data structure, but not yet specified : https://github.com/TazeTSchnitzel/Firth/issues/18

hikari-no-yume commented 9 years ago

We could just do what Node does, yes, and export everything with an object.

On the other hand, I don't like having to look at the bottom of the file to see what's exported. I'd prefer something along these lines:

/foobar [
    ; ...
] def.
/foobar foobar export.

Or perhaps a combined def-and-export function. Though it's probably best to keep things simple and only have one function that can modify the scope.

mathroc commented 9 years ago

the export function could be nice, with only def. module would likely export to much stuff without realizing it

hikari-no-yume commented 9 years ago

Right. If you implicitly export everything, then it's way too easy to accidentally expose something.

raoulvdberge commented 9 years ago

People will be lazy and will just use that special def for everything without thinking about it, so export would be better indeed.