Naming of type objects #14
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
For each type there will be the explicit conversion method, and the type object itself. These must be different, because generic types are callable as functions:
Complex(BigNumber)
, for example, will produce a high-precision complex number type. This leads to some questions:(A) I am unclear on whether we will need separate methods for type predicates: we will be able to write
math.BigNumber.test(x)
to determine ifx
is a BigNumber, so do we also need something likemath.isBigNumber(x)
?(B) I am pretty sure we want to stick with
number
,boolean
,string
, etc. as the explicit conversion methods. So to keep them closely associated, I was going to call the type objectsNumber
,Boolean
,String
, etc. However, I just had a confusing bug because those names are already used in standard JavaScript (exactly for its explicit conversion operators). So I would like to use different names. What should they be?For now in the prototype I am going to:
(A) assume the answer is no, we don't need type predicates aside from
TheType.test(x)
(B) name type objects corresponding to built-in types (only), where the preferred type object name is already in use, by adding a
T
suffix to that:NumberT
,BooleanT
, etc.However, I would definitely be happy to have feedback on these issues, and will have no issues changing over to any better system should we come up with one.