arturo-lang / arturo

Simple, expressive & portable programming language for efficient scripting
http://arturo-lang.io
MIT License
707 stars 32 forks source link

[Converters\from] Do we really need this? #676

Open github-actions[bot] opened 2 years ago

github-actions[bot] commented 2 years ago

[Converters\from] Do we really need this?

We can definitely support hex/binary literals, but how would we support string to number conversion? Perhaps, with .to and option?

It's basically rather confusing...

https://github.com/arturo-lang/arturo/blob/65e1cf749c1d12727a29db43e2777c75bd17178b/src/library/Converters.nim#L824

            push(newDictionary(dict))

    # TODO(Converters\from) Do we really need this?
    #  We can definitely support hex/binary literals, but how would we support string to number conversion? Perhaps, with `.to` and option?
    #  It's basically rather confusing...
    #  labels: library, cleanup, enhancement, open discussion
    builtin "from",
        alias       = unaliased, 
        rule        = PrefixPrecedence,
        description = "get value from string, using given representation",
        args        = {
            "value" : {String,Literal}
        },
        attrs       = {
            "binary"    : ({Logical},"get integer from binary representation"),
            "hex"       : ({Logical},"get integer from hexadecimal representation"),
            "octal"     : ({Logical},"get integer from octal representation"),
            "opcode"    : ({Logical},"get opcode by from opcode literal")
        },
        returns     = {Any},
        # TODO(Converters\from) add documentation example for `.opcode`
        #  labels: library, documentation, easy
        example     = """
            print from.binary "1011"        ; 11
            print from.octal "1011"         ; 521

312faed80a2b467b618f484770181e21b8c70837

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 1 year ago

Closing issue as stale.

stale[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.