Nested Degenerate Convenience Methods

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Nested Degenerate Convenience Methods

Sean P. DeNigris
Administrator
Is there a name for the following pattern?

doSomething: arg1
  ^ self doSomething: arg1 ifA: arg2Default

doSomething: arg1 ifA: arg2
  ^ self doSomething: arg1 ifA: arg2 ifB: arg3Default
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Nested Degenerate Convenience Methods

Paul DeBruicker
https://en.wikipedia.org/wiki/Currying

Sean P. DeNigris wrote
Is there a name for the following pattern?

doSomething: arg1
  ^ self doSomething: arg1 ifA: arg2Default

doSomething: arg1 ifA: arg2
  ^ self doSomething: arg1 ifA: arg2 ifB: arg3Default
Reply | Threaded
Open this post in threaded view
|

Re: Nested Degenerate Convenience Methods

damien.pollet
In reply to this post by Sean P. DeNigris
Hi Sean, I'm using "implicit default" or "implicit argument" for the chains of less and less terse methods that eventually call the fully-explicit canonic one. There is a related idiom where the explicit argument is a block, and the implicit version either results in a sentinel value or signals an exception, e.g. ifAbsent/ifNone. This one I call "default case handler".

In either case, I'm not convinced the name is that clear, so if you get by a nice one, I'm interested.


> On 01 Apr 2015, at 18:49, Sean P. DeNigris <[hidden email]> wrote:
>
> Is there a name for the following pattern?
>
> doSomething: arg1
>  ^ self doSomething: arg1 ifA: arg2Default
>
> doSomething: arg1 ifA: arg2
>  ^ self doSomething: arg1 ifA: arg2 ifB: arg3Default
>
>
>
> -----
> Cheers,
> Sean
> --
> View this message in context: http://forum.world.st/Nested-Degenerate-Convenience-Methods-tp4816719.html
> Sent from the ESUG mailing list archive at Nabble.com.
>
> _______________________________________________
> Esug-list mailing list
> [hidden email]
> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org

--
Damien Pollet
type less, do more [ | ] http://people.untyped.org/damien.pollet




_______________________________________________
Esug-list mailing list
[hidden email]
http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
Reply | Threaded
Open this post in threaded view
|

Re: Nested Degenerate Convenience Methods

Andres Valloud-4
In reply to this post by Sean P. DeNigris
I would call that code an example of "convenience methods".  In C, those
things would likely be implemented in terms of "macros".  The term
"pattern" is overloaded, I wouldn't use it here.

On 4/1/15 9:49 , Sean P. DeNigris wrote:

> Is there a name for the following pattern?
>
> doSomething: arg1
>    ^ self doSomething: arg1 ifA: arg2Default
>
> doSomething: arg1 ifA: arg2
>    ^ self doSomething: arg1 ifA: arg2 ifB: arg3Default
>
>
>
> -----
> Cheers,
> Sean
> --
> View this message in context: http://forum.world.st/Nested-Degenerate-Convenience-Methods-tp4816719.html
> Sent from the ESUG mailing list archive at Nabble.com.
>
> _______________________________________________
> Esug-list mailing list
> [hidden email]
> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>

_______________________________________________
Esug-list mailing list
[hidden email]
http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
Reply | Threaded
Open this post in threaded view
|

Re: Nested Degenerate Convenience Methods

Joseph Pelrine
I agree with Andres about calling it a convenience method (and also not
calling it a pattern), but is this not also an example of currying?

Best
Joseph
On 02.04.15 00:49, Andres Valloud wrote:

> I would call that code an example of "convenience methods".  In C, those
> things would likely be implemented in terms of "macros".  The term
> "pattern" is overloaded, I wouldn't use it here.
>
> On 4/1/15 9:49 , Sean P. DeNigris wrote:
>> Is there a name for the following pattern?
>>
>> doSomething: arg1
>>    ^ self doSomething: arg1 ifA: arg2Default
>>
>> doSomething: arg1 ifA: arg2
>>    ^ self doSomething: arg1 ifA: arg2 ifB: arg3Default
>>
>>
>>
>> -----
>> Cheers,
>> Sean
>> --
>> View this message in context:
>> http://forum.world.st/Nested-Degenerate-Convenience-Methods-tp4816719.html
>>
>> Sent from the ESUG mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> Esug-list mailing list
>> [hidden email]
>> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>>
>
> _______________________________________________
> Esug-list mailing list
> [hidden email]
> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>
>

--
Joseph Pelrine [ | ]
MetaProg GmbH
Email: [hidden email]
Web:   http://www.metaprog.com

As soon as you introduce people, things become complex.

_______________________________________________
Esug-list mailing list
[hidden email]
http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
Reply | Threaded
Open this post in threaded view
|

Re: Nested Degenerate Convenience Methods

Andres Valloud-4
... /me reads Wikipedia article ...

It sure looks like an example of currying!

On 4/1/15 22:14 , Joseph Pelrine wrote:

> I agree with Andres about calling it a convenience method (and also not
> calling it a pattern), but is this not also an example of currying?
>
> Best
> Joseph
> On 02.04.15 00:49, Andres Valloud wrote:
>> I would call that code an example of "convenience methods".  In C, those
>> things would likely be implemented in terms of "macros".  The term
>> "pattern" is overloaded, I wouldn't use it here.
>>
>> On 4/1/15 9:49 , Sean P. DeNigris wrote:
>>> Is there a name for the following pattern?
>>>
>>> doSomething: arg1
>>>    ^ self doSomething: arg1 ifA: arg2Default
>>>
>>> doSomething: arg1 ifA: arg2
>>>    ^ self doSomething: arg1 ifA: arg2 ifB: arg3Default
>>>
>>>
>>>
>>> -----
>>> Cheers,
>>> Sean
>>> --
>>> View this message in context:
>>> http://forum.world.st/Nested-Degenerate-Convenience-Methods-tp4816719.html
>>>
>>>
>>> Sent from the ESUG mailing list archive at Nabble.com.
>>>
>>> _______________________________________________
>>> Esug-list mailing list
>>> [hidden email]
>>> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>>>
>>
>> _______________________________________________
>> Esug-list mailing list
>> [hidden email]
>> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>>
>>
>

_______________________________________________
Esug-list mailing list
[hidden email]
http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
Reply | Threaded
Open this post in threaded view
|

Re: Nested Degenerate Convenience Methods

Reinout Heeck-3
In reply to this post by Sean P. DeNigris

Nested Degenerate Convenience Methods

I don't have a better name, but maybe a bit of critique helps:

I would say that these methods are degenerate when viewed from a
bottom-up perspective.
Thinking top-down we could say that some parameters are implied by the
environment (self in this case) hence such methods are more abstract.

I guess this might dovetail with Damiens suggestions depending on usage.
Is it a pattern when it is used in a situation to hide certain concerns
-- when it is used particularly to reach abstraction, to 'give'
abstraction to higher layers?


R
-


On 4/1/2015 6:49 PM, Sean P. DeNigris wrote:

> Is there a name for the following pattern?
>
> doSomething: arg1
>    ^ self doSomething: arg1 ifA: arg2Default
>
> doSomething: arg1 ifA: arg2
>    ^ self doSomething: arg1 ifA: arg2 ifB: arg3Default
>
>
>
> -----
> Cheers,
> Sean
> --
> View this message in context: http://forum.world.st/Nested-Degenerate-Convenience-Methods-tp4816719.html
> Sent from the ESUG mailing list archive at Nabble.com.
>
> _______________________________________________
> Esug-list mailing list
> [hidden email]
> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>

_______________________________________________
Esug-list mailing list
[hidden email]
http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
Reply | Threaded
Open this post in threaded view
|

Re: Nested Degenerate Convenience Methods

Steven Kelly
In reply to this post by Andres Valloud-4
I'd say it's similar to currying, but not actual currying.
1) In this Smalltalk pattern, the extra default argument is fixed, provided
at compile time; with currying, the extra argument is provided at runtime.
2) In Smalltalk, the result of any of the methods is the actual return value,
whereas in currying it's a function until the last case.

This is more like partial function application:
http://en.wikipedia.org/wiki/Currying#Contrast_with_partial_function_applicat
ion
but that only solves 2), not 1). Blocks can go all the way.

I'm not a functional programming expert, though!

Steve


Andres Valloud wrote April 2, 2015 11:38 AM:

> ... /me reads Wikipedia article ...
>
> It sure looks like an example of currying!
>
> On 4/1/15 22:14 , Joseph Pelrine wrote:
> > I agree with Andres about calling it a convenience method (and also
> not
> > calling it a pattern), but is this not also an example of currying?
> >
> > Best
> > Joseph
> > On 02.04.15 00:49, Andres Valloud wrote:
> >> I would call that code an example of "convenience methods".  In C,
> those
> >> things would likely be implemented in terms of "macros".  The term
> >> "pattern" is overloaded, I wouldn't use it here.
> >>
> >> On 4/1/15 9:49 , Sean P. DeNigris wrote:
> >>> Is there a name for the following pattern?
> >>>
> >>> doSomething: arg1
> >>>    ^ self doSomething: arg1 ifA: arg2Default
> >>>
> >>> doSomething: arg1 ifA: arg2
> >>>    ^ self doSomething: arg1 ifA: arg2 ifB: arg3Default
> >>>
> >>>
> >>>
> >>> -----
> >>> Cheers,
> >>> Sean
> >>> --
> >>> View this message in context:
> >>> http://forum.world.st/Nested-Degenerate-Convenience-Methods-
> tp4816719.html
> >>>
> >>>
> >>> Sent from the ESUG mailing list archive at Nabble.com.
> >>>
> >>> _______________________________________________
> >>> Esug-list mailing list
> >>> [hidden email]
> >>> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
> >>>
> >>
> >> _______________________________________________
> >> Esug-list mailing list
> >> [hidden email]
> >> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
> >>
> >>
> >
>
> _______________________________________________
> Esug-list mailing list
> [hidden email]
> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org

_______________________________________________
Esug-list mailing list
[hidden email]
http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org