arturo-lang / arturo

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

[Converters\as] do we really need this? #1381

Open github-actions[bot] opened 9 months ago

github-actions[bot] commented 9 months ago

[Converters\as] do we really need this? judging from the options, we have 3 that are number related: .binary, .hex, .octal (and they are identical as the option for from; only doing the reverse operation), we have one that converts a string to ascii (!) - this could go as a separate function into the Strings module? - and the rest of the options are pretty much code-related: .code, .pretty, & .unwrapped are for converting a value to Arturo code (could also become one separate function) and .data works like a Collections/dictionary option (it does return a dictionary, doesn't it - not sure!). Sure thing is, we should either eliminate this module altogether, or rename it, and/or split the existing functions into different sub-functions, and/or distribute these sub-functions to different existing modules. (What am I writing here?! Who knows...)

https://github.com/arturo-lang/arturo/blob/411617a1906063cf0adfd3ac06804dc4b29403a0/src/library/Converters.nim#L66

import sequtils, strformat

import helpers/datasource

when not defined(NOASCIIDECODE):
    import helpers/strings

import vm/lib
import vm/[bytecode, errors, opcodes, parse]

import vm/values/printable

#=======================================
# Definitions
#=======================================

# TODO(Converters) resolving `from`/`to`/`as` clutter?
#  Right now, we have 4 different built-in function performing different-but-similar actions.
#  Is there any way to remove all ambiguity - by either reducing them, merging them, extending them or explaining their functionality more thoroughly?
#  labels: library, enhancement, open discussion, documentation

proc defineLibrary*() =

    #----------------------------
    # Functions
    #----------------------------

    # TODO(Converters\as) is `.unwrapped` working as expected?
    #  labels: library, bug

    # TODO(Converters\as) do we really need this?
    #  judging from the options, we have 3 that are number related:
    #  `.binary`, `.hex`, `.octal` (and they are identical as the
    #  option for `from`; only doing the reverse operation), we have
    #  one that converts a string to ascii (!) - this could go as a 
    #  separate function into the Strings module? - and the rest of
    #  the options are pretty much code-related: `.code`, `.pretty`,
    #  & `.unwrapped` are for converting a value to Arturo code 
    #  (could also become one separate function) and `.data` works
    #  like a Collections/dictionary option (it does return a dictionary,
    #  doesn't it - not sure!). Sure thing is, we should either eliminate
    #  this module altogether, or rename it, and/or split the existing functions
    #  into different sub-functions, and/or distribute these sub-functions
    #  to different existing modules. (What am I writing here?! Who knows...)
    #  labels: library, cleanup, open discussion
    builtin "as",
        alias       = unaliased,
        op          = opNop,

99c7aba7e5c1231f940f8ea91fbb20276a1de213

stale[bot] commented 1 month 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.