Search code examples
programming-languagesprototypeiolanguage

In Io language, what's the difference between 1 proto and 1 type?


Io> 1 proto == Number
==> true
Io> 1 type == Number
==> false
Io> 1 proto
==> 0
Io> 1 type
==> Number

I'm very confused about this. Does anyone have ideas about this?


Solution

  • It's because type is a sequence whereas protos are a list of objects.

    Io> (1 proto) type
    ==> Number
    
    Io> 1 hasProto("Number")
    ==> false
    
    Io> 1 hasProto(Number)
    ==> true
    
    Io> (1 type) type
    ==> Sequence
    
    Io> 1 type == "Number"
    ==> true
    

    What is interesting is that...

    Io> 1 protos
    ==> list(0)
    

    ... instead of returning list(Number). But with 0 (zero) being a Number object then I suspects this doesn't cause protos a problem!