Re: Opinion on ERXKey type parameterization
Re: Opinion on ERXKey type parameterization
- Subject: Re: Opinion on ERXKey type parameterization
- From: Samuel Pelletier <email@hidden>
- Date: Thu, 30 Mar 2017 10:14:07 -0400
Paul,
I never used and didi not even known the existence of ERXGenericRecord.valueForKey(). The problem with these powerful ERXKey is that some operator will reduce a collection and some will create a collection. There is no way to infer these results with the current way they are done (using generics). I see no way to make the ERXGenericRecord.valueForKey() type to work all the time.
For simple key this may works but with key path, things get very complex.
For exemple traversing 2 toMany relationships will return an array of array of the final type that can be reduced to a single level array using atFlatten() and this one to a single object with atObjectAtIndex(index) or atMax(), ...
A new method could be added to return a new no-op key with the NSArray version of the type to use with ERXGenericRecord.valueForKey() if required. As I do not know where ERXGenericRecord.valueForKey is used, I cannot comment on this.
This complexity may explain the proposition to have a native equivalent in Swift, they probably want make sure it will always works by having a better knowledge of the effect of operations chain.
Samuel
> Le 29 mars 2017 à 19:40, Paul Hoadley <email@hidden> a écrit :
>
> On 29 Mar 2017, at 09:19, Paul Hoadley <email@hidden> wrote:
>
>> Anyone else got any thoughts on all this?
>
>
> I see it was discussed on the old Wonder list back in 2009. Dave Avendasora asked the exact question I asked:
>
>> Since this is a to-many relationship shouldn't it be "ERXKey<NSArray<ScheduledRoutingRelationship>>"?
>
>
> And Mike Schrag answered:
>
>> no it just doesn't really work this way ... if it did this, it's easy to extend it to add the array, but it's impossible to deconstruct it to get the inner type. there are methods to extend keys, etc with array variants for most operations, but you rarely actually want the type of the key to be NSArray<T>
>
>
> Along with Samuel’s observations, seems like case closed. It does still seem to leave ERXGenericRecord.valueForKey(ERXKey<T> key) broken in the case of to-many relationship ERXKeys, though, doesn’t it? (Worse, it will break at runtime.)
>
>
> --
> Paul Hoadley
> http://logicsquad.net/
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden