Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #33387
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Today I invented ... the downcast! |
| Date | 2015-12-24 15:12 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <n5hje9$lpa$1@dont-email.me> (permalink) |
| References | <downcast-20151224203323@ram.dialup.fu-berlin.de> |
On 12/24/2015 2:39 PM, Stefan Ram wrote:
> What do you all thing about it?
Meh.
> Example of the intended usage:
>
> final android.widget.LinearLayout.LayoutParams parameters
> = downcast( params );
>
> Definition:
>
> static private final< T, O >T downcast( O x ){ return( T )x; }
>
> Main Advantage (that's why I wrote it):
>
> - the programmer conveys his intention that this
> cast is intended to be a /down/cast
Since an /up/cast requires no cast operator at all, the mere
presence of the cast is a pretty good indicator. Besides,
String s = "I feel sad and downcast. (:";
Object o = downcast(s); // "down?"
> Advantages that are mere side-effects of the implementation:
>
> - the programmer does not actually have to write
> the target type, which is deduced
>
> Disadvantage:
>
> - It has not yet been extensively tested
>
> - It does not check at compile time whether T
> really is a /sub/type of O.
... thus converting a compile-time error into a run-time error,
a wrong in the step direction. Hmm: I withdraw my "Meh" above, and
change it instead to "Ugh."
--
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Today I invented ... the downcast! Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-12-24 15:12 -0500 Re: Today I invented ... the downcast! Lew <lewbloch@gmail.com> - 2015-12-24 13:11 -0800
csiph-web