Hacker News new | ask | show | jobs
by gonzus 382 days ago
Nice work. Some questions / observations:

Can you add methods to any type? There is an example of adding a method to a builtin type (string) -- can you add also add a method to a union type?

Any plans to add some sort of enum type? If yes, will it be possible to add methods to enums?

How do you support (or intend to support) Unicode? It says "Strings use ASCII encoding" -- why not UTF8?

The example with a timeout channel does not show how / when the timeout will be triggered. Is this a special kind of channel?

It says "Packages will be synchronized to the $HOME/.nature/package directory" -- will this respect the XDG standard directory structure, which defaults to $HOME/{.cache,.local,.config}?

1 comments

1. nature can add methods to built-in types, example

fn int.to_string() { }

I haven't considered whether union types can add methods, so I tested it, and it seems to be possible, but this may cause some unexpected behavior, so maybe I should disable this possibility for now.

type test_t = int|null

fn test_t.hello() { println('hello world') }

2. Enum support is planned. I plan to use type declarations. Why hasn't enum been added yet? Nature has adopted a conservative syntax design, and I hope to hear more opinions and avoid affecting existing functionality as much as possible when adding syntax features.

type weekly = enum {}

So methods can be added to enums.

fn weekly.found() { }

3. UTF-8 should be solvable via a library. I haven't thought much about UTF-8 yet, but if it can enhance nature's usability, I'll implement it as soon as possible. Usability is a key focus for nature moving forward.

4. Select{} timeout handling does require a special timer channel, which will be addressed in the standard library. Currently, it can only be handled via ch.try_recv() and ch.try_send(), which do not block the channel.

5. Actually, this is the first time I've heard of the XDG standard. I will study and understand the specification.

---

I am not an experienced programming language designer, so thank you for your questions. I will carefully consider them.