I want to Typename{T,N} as Abstract onlyif Typename.abstract==true, 
otherwise Typename.abstract==false and I want to treat it as Concrete

Milan's solution displays the subtypes immediately. The way it is set  up 
is neat -- but how to pull the targeted type out of the body?

I need this to be a callable function that yields a manipulable tuple or 
vector or tuple of subtuples or  etc.


   

On Wednesday, February 10, 2016 at 3:26:14 AM UTC-5, Tommy Hofmann wrote:
>
> I think the recursive solution of Milan will give you a finite list of all 
> subtypes. But the list will contain things like Array{T, N}, that is, a 
> type with a parameter. How do you handle those? Do you want to count them 
> as abstract or concrete?
>
> On Wednesday, February 10, 2016 at 9:10:16 AM UTC+1, Jeffrey Sarnoff wrote:
>>
>> Hello Tommy,
>>
>> OK, putting off inclusion of recursive types ...
>> and ignoring all possible values for the parameters of a parameterized 
>> type unless already explicitly defined (present in memory) ...
>>
>>     allsupertypes(T) should be a short list from T to supertype(T) to 
>> supertype(supertype(T)) .. to Any
>>
>>     allsubtypes(T) seems obtainable 
>>     I can throw things into a tree until the leaves have no subtypes, 
>> then traverse it; is there a nice way to do that implicitly within a 
>> function?
>>
>>    
>>
>>
>> On Wednesday, February 10, 2016 at 2:32:35 AM UTC-5, Tommy Hofmann wrote:
>>>
>>> You implicitly assume that a type has only finitely many sub/supertypes, 
>>> which for arbitrary types is clearly not the case. The simplest example is 
>>> Any but you can also get this behavior when defining recursive types. More 
>>> generally, given types TL, TU there is no way of returning all types T with 
>>> TL <: T <: TU. You can describe this set using TypeVar, but you cannot just 
>>> write it down.
>>>
>>> Tommy
>>>
>>> On Wednesday, February 10, 2016 at 12:50:43 AM UTC+1, Jeffrey Sarnoff 
>>> wrote:
>>>>
>>>> I see that your definition pours the subtypes from a pitcher of the 
>>>> poured subtypes.  The note about parametric types is well pointed. -- 
>>>> Jeffrey
>>>>
>>>> Clearly, the answer is therein.  Cloudily, I'm looking.
>>>>
>>>>
>>>> On Tuesday, February 9, 2016 at 3:43:48 PM UTC-5, Milan Bouchet-Valat 
>>>> wrote:
>>>>>
>>>>> Le mardi 09 février 2016 à 12:24 -0800, Jeffrey Sarnoff a écrit : 
>>>>> > Any advice on quick 'n EZ coding of something like these? 
>>>>> > 
>>>>> > allsupertypes(Irrational) == ( Real, Number, Any ) 
>>>>> > 
>>>>> > allsubtypes(Integer) == ( BigInt, Bool,  Signed, 
>>>>> Int128,Int16,Int32,Int64,Int8, Unsigned, 
>>>>> UInt128,UInt16,UInt32,UInt64,UInt8 ) 
>>>>> > abstractsubtypes(Integer) == ( Signed, Unsigned ) 
>>>>> > concretesubtypes(Integer) == ( 
>>>>> BigInt,Bool,UInt128,UInt16,UInt32,UInt64,UInt8,UInt16,UInt32,UInt64,UInt8)
>>>>>  
>>>>> Here's a way to get all concretes ubtypes: 
>>>>> subtypestree(x) = length(subtypes(x)) > 1 ? map(subtypestree, 
>>>>> subtypes(x)) : x 
>>>>> [subtypestree(AbstractArray)...;] 
>>>>>
>>>>> You should be able to adapt this to return all abstract types instead 
>>>>> by using isleaftype() (which would better be called 
>>>>> isconcretetype()?). 
>>>>> But note there's the special case of parametric types, which aren't 
>>>>> leaf types. 
>>>>>
>>>>>
>>>>> Regards 
>>>>>
>>>>

Reply via email to