3 ms·
Yes, I've seen Any (or top) described like that. It is the super-type of all types. Therefore, as you say, "Any value in your type system belongs to the top typ
by igravious 11y ago
Yes, I've seen Any (or top) described like that. It is the super-type of all types. Therefore, as you say, "Any value in your type system belongs to the top type". Imagine the following:
foo = Sheep.new => a sheep
foo.is_a(Any) => true (for anything! by the nature of Any)
I agree that "some" looks like "any". I wonder is there any (ahem) semantic difference in the context we are considering.
I can see why you would say that (every)thing is the "and" of all my types. But consider that I think it obvious that (every)thing should cover all things, this would include instantiations of types as well as the types themselves.
Programming environment-wise I'm having a hard time imagining how "everything" would work. It must be related to for_all or universal quantification somehow...
- jerf 11y ago"Programming environment-wise I'm having a hard time imagining how "everything" would work." It may be worth taking a moment to skip out on the abstraction and look more at the representation layer. In the general case, in most if not all implementations, "Any" basically translates to a "Variant" type: https://en.wikipedia.org/wiki/Variant_type https://en.wikipedia.org/wiki/Variant_type "Dynamically-typed languages" are basically those languages where all variables have the type Any. (The values generally have specific types, but the variables are all Any.)
- junke 11y ago> But consider that I think it obvious that (every)thing should cover all things, this would include instantiations of types as well as the types themselves. Types are there to describe the values that can be manipulated by your program. So "as well as the types themselves" is only a concern if your language can manipulate types as first-class values. And this is not so different from all the other types in your language, at this point. What property should a value hold to belong to the "everything" type, then?