old-design-docs
old-design-docs copied to clipboard
RFC: Replace unibool with uniprop-bool in S15
The current spec says uniprop returns the narrowest numerical type for numerical properties and boolean for boolean properties, and returns Str for all other properties.
It also mentions a unibool function. At the moment we have uniprop-bool, uniprop-int, uniprop-str in Rakudo, but they are not in the docs or Roast. I think the only useful one of these we might want to keep would be the uniprop-bool function, which could be used to check the absence of a property.
This code below shows an example I think makes logical sense, and is also currently what Rakudo does.
'a'.uniprop-bool('Numerical_Type') #> False
'a'.uniprop-bool('Hangul_Syllable_Type') #> False
'a'.uniprop('Numerical_Type') #> None
'읔'.uniprop('Hangul_Syllable_Type') #> NVT
See discussion here: https://irclog.perlgeek.de/perl6/2016-12-16#i_13751405 @jnthn
Nobody has commented yet, can anybody weigh in? @perl6/perl6
If no objections I would like to update the spec and add some tests into roast for this.
To be honest, I'm not sure I understand what is going to happen after this change.
I think the only useful one of these we might want to keep would be the uniprop-bool function, which could be used to check the absence of a property.
Can't we have something that is more consistent with the rest of the language? For example, uniprop can return an undefined value in case of the absence of a property. Or we can add :exists or something like this.
Well, just :exists is pretty vague when you want to return whether or not the property is True or False. Could be other wording, but there should be an easy way to check if
'a'.uniprop('Numerical_Type') #> None
'a'.uniprop-bool('Numerical_Type') #> False
All the different enumerated properties have mostly different values for codes without the property OR which have been explicitly specified as having that value.
:exists, well that codepoint does have said property, and returning undefined for standard uniprop would not be correct.