arturo-lang / arturo

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

[Quantities] erroneous module name for property predicates #1398

Open github-actions[bot] opened 11 months ago

github-actions[bot] commented 11 months ago

[Quantities] erroneous module name for property predicates For any of the, automatically-generated, property predicates, e.g. mass? the module shown when we do e.g. info'mass? is always macros - which is basically the file that Nim considers to be the current one (= Nim stdlib's macros module), and that's what we pick by mistake...

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

                    push(newUnit(x.u))

    #----------------------------
    # Predicates
    #----------------------------

    builtin "conforms?",
        alias       = colonequal,
        op          = opNop,
        rule        = InfixPrecedence,
        description = "check if given quantities/units are compatible",
        args        = {
            "a"     : {Quantity, Unit},
            "b"     : {Quantity, Unit}
        },
        attrs       = NoAttrs,
        returns     = {Logical},
        example     = """
            conforms? 3`m `m                ; => true
            conforms? 4`m `cm               ; => true

            4`yd := 5`m                     ; => true
            5`m := `s                       ; => false
            ..........
            givenValue: 6`yd/s      

            conforms? givenValue `m         ; => false
            conforms? givenValue `km/h      ; => true
            ..........
            3`m := 4`m                      ; => true
            5`W := 5`N                      ; => false
            5`W := 3`J/s                    ; => true
        """:
            #=======================================================
            if xKind == Quantity:
                if yKind == Quantity:
                    push newLogical(x.q =~ y.q)
                else:
                    push newLogical(x.q =~ y.u)
            else:
                if yKind == Quantity:
                    push newLogical(x.u =~ y.q)
                else:
                    push newLogical(x.u =~ y.u)

    # TODO(Quantities) erroneous module name for property predicates
    #  For any of the, automatically-generated, property predicates,
    #  e.g. `mass?` the module shown when we do e.g. `info'mass?` is
    #  always `macros` - which is basically the file that Nim considers
    #  to be the current one (= Nim stdlib's macros module), and that's
    #  what we pick by mistake...
    #  labels: library, bug
    addPropertyPredicates()

    #----------------------------
    # Constants
    #----------------------------

    when not defined(NOGMP):
        addPhysicalConstants()

#=======================================
# Add Library
#=======================================

Libraries.add(defineLibrary)
ndex e17a0919e6..3421fafd5e 100644
++ b/src/library/Reflection.nim

899218c400634b97ff01d8eaab4ba28be8635991

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