haumea-lang / haumea-rs

Haumea is an experimental language designed to be simple and easy to learn and program in.
MIT License
7 stars 2 forks source link

Modules? #19

Closed BookOwl closed 7 years ago

BookOwl commented 7 years ago

I would be nice to allow people to write modules in Haumea. This would make the language much more usable for real word stuff and for learning programming in.

bates64 commented 7 years ago

And a standard library?

BookOwl commented 7 years ago

Yep.

TheMonsterFromTheDeep commented 7 years ago

Speaking of which, how are libraries going to work in Haumea? I suppose they will be C-like (i.e. separate header file and compiled code) but is there any syntax for function forward-declarations yet?

BookOwl commented 7 years ago

Speaking of which, how are libraries going to work in Haumea?

I have no clue. :P I've just been making issues for things that I want to add eventually.

I suppose they will be C-like (i.e. separate header file and compiled code) but is there any syntax for function forward-declarations yet?

I don't know and no.

TheMonsterFromTheDeep commented 7 years ago

As haumea is a compiled language, I think C-like libraries are a good option, because that also introduces precompiled files for modularized programs, which makes compilation times much much shorter.

The problem, of course, is that the concept is just a little arcane for those new to programming (I, in fact, only really understood the point of C header files a few months ago, when I started programming C seriously)

Maybe haumea could treat all files like header files (that is, read the function prototypes from their defining files), and then use a precompiled binary if one was available? (sort of like an automatic makefile system)

bates64 commented 7 years ago

As haumea is a compiled language, I think C-like libraries are a good option, because that also introduces precompiled files for modularized programs, which makes compilation times much much shorter.

I'd say just cache things in /tmp or something.

bates64 commented 7 years ago
import foo /* defines and imports module "foo" [object/dict, will need this datatype] */
import bar as baz /* imports module "bar" but defines it as "baz" */
bates64 commented 7 years ago

Also this may need some sort of repository - like npm or Cargo - with a CLI (and perhaps website). We could base it off of GitHub..

# installs https://github.com/nanalan/somemodule.git as module
$ haumea install nanalan/somemodule
$ touch hello.hau
$ echo "import nanalan/somemodule as somemodule" >> hello.hau
$ haumea run hello.hau # bam!

But this is a far-off thing.

BookOwl commented 7 years ago

I was actually thinking about using use for importing modules, since it seems a bit more intuitive for non-programmers than import

use math
use foo as bar
BookOwl commented 7 years ago

As far as a repository goes, we could definitely use Github, at least for the first version. I would like to make a separate repository eventually, since that would make it far easier for users to find packages.

BookOwl commented 7 years ago

Moving to haumea-lang/thinktank