arturo
arturo copied to clipboard
[Converters\from] Do we really need this?
[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