h3rald / min

A small but practical concatenative programming language and shell
https://min-lang.org
MIT License
311 stars 23 forks source link

Parameter Problem #75

Closed ghost closed 3 years ago

ghost commented 3 years ago

In operator defining, we initialize params with a default value and there is no generics.

ghost commented 3 years ago

Is there a type which means all types?

h3rald commented 3 years ago

Is there a type which means all types?

Yes, you can use a as a type definition. At present you can use:

...and you can also use unions, e.g. dict|null.

Keep in mind that you can use the set-type operator to set the type flag on a dictionary on whatever you want.

What are you looking for? I wouldn't like to include generics really... I would like to keep the language more dynamic, currently I don't see the need, but I may be wrong! What's your use case exactly?

ghost commented 3 years ago
(!) ./src/utils.min(145,9) [a]: Undefined symbol 'a'
    ./src/utils.min(145,9) in symbol: a
    ./src/utils.min(145,13) in symbol: apply
    ./src/utils.min(145,13) in symbol: =>
    src\base.min(4,20) in symbol: call
    src\base.min(4,20) in symbol: invoke
    src\base.min(4,20) in symbol: *utils/toStr
h3rald commented 3 years ago

What did you try to do exactly? a can only be used within an operator signature quotation...

ghost commented 3 years ago

Code:

( symbol toStr
    (a :element ==> string :result)
    (
        "$1" (a) => % @result
    )
) ::
h3rald commented 3 years ago

The body should be the following:

"$1" (element) => % @result

a is the type, not the name of the captured symbol 😉

ghost commented 3 years ago

The body should be the following:

"$1" (element) => % @result

a is the type, not the name of the captured symbol 😉

Yes, my faulting. 👍 a is a type but i wrote wrongly. typographic error 😄