#23 add built in functions isrecord, isclass, ...

open
nobody
None
5
2003-04-23
2003-04-23
No

I know of no fast proc for these. Kludge
(key(x)\1=="__s") # iff x is a record else may runerr

islist, isset, istable would be nice too - and faster than
type(v)=="_"
in a proc for coercions is even slower.

isstring, isinteger, isreal, isnumeric
would be good since they would not convert their args
x:=isstring(y) vs type(y)=="string" & x:=y

isscalar(x) vs type(x)=="integer"|"real"|"&null" # can't !x

Discussion

  • Charles Evans

    Charles Evans - 2003-05-19

    Logged In: YES
    user_id=436876

    procedure isrecord(x)
    static t
    initial {t:=set();every insert(t,"string","real","integer","table",
    "file","cset","set","null","window","procedure","list",
    "co-expression","external")}
    member(t,type(x))|return x
    end
    BUT
    record external(a)
    isrecord( external(1))
    will FAIL
    ditto for record window(a), record null(a)

     
  • Charles Evans

    Charles Evans - 2003-05-26

    Logged In: YES
    user_id=436876

    isclass:
    type(x) ? find("_state") & key(x)\1 == "__s"

     
  • Nobody/Anonymous

    Testing a patch.
    cvevans

     

Log in to post a comment.