Re: Why we should (not?) have closures after all
- From: Hendrik Maryns <gtw37bn02@xxxxxxxxxxxxxx>
- Date: Thu, 23 Oct 2008 16:31:28 +0200
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Patrick May schreef:
Andreas Leitgeb <avl@xxxxxxxxxxxxxxxxxxxxxxxx> writes:
Patrick May <pjm@xxxxxxx> wrote:
Speaking in the abstract, consider the declaration of a standardIf you entirely get rid of any type spec before the variable, then the
collection type in Java:
Map<String,Observer> registeredObservers = new HashMap<String,Observer>();
That's a lot of text, most of which Java programmers learn to skim over
quickly. Much of it is redundant. It is possible to retain static
typing, if you really want it, without requiring so much text. For
example:
registeredObservers = new HashMap<String,Observer>();
distinction between merely setting a variable and declaring plus
initializing a new one is lost, and this could lead to nasty effects,
if instead of a local variable suddenly a field (Perhaps newly added
as "protected" to some base-class)
That's possible, but essentially an artifact of the syntax I
chose. A "var" keyword or a construct like
"new registeredObservers:HashMap<String,Observer>();" would achieve the
same goal. My point was that the explicit typing of Java does
significantly increase its verbosity.
registeredObservers = new HashMap();No, no, That goes ways too far. This is where we leave the domain of
The allowed types of the key and value can be determined from the
use of the variable at compile time.
strict typing, which (unlike "repetitive verbose" typing) I don't
think we should leave.
That construct still allows for strong, if not completely strict,
typing. I agree with you that it probably doesn't fit well with
traditional Java style, but it still allows the compiler to catch type
errors.
The question is whether you want the compiler to catch type errors (of
course), or whether you want the programmer to see them (also, no?). In
you suggested reduced syntax, the compiler may have no problem with it,
but for the (maintenance) programmer, it is much more difficult to find
out what type a variable has.
H.
- --
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iEYEARECAAYFAkkAisAACgkQBGFP0CTku6O0tACbBBI9iNzshjpqtuQz/Ga61RPy
bgYAoLrDBr4HtzbPxBDGN9MiDo23U9U9
=6eel
-----END PGP SIGNATURE-----
.
- Follow-Ups:
- Re: Why we should (not?) have closures after all
- From: Patrick May
- Re: Why we should (not?) have closures after all
- From: Andreas Leitgeb
- Re: Why we should (not?) have closures after all
- From: Lew
- Re: Why we should (not?) have closures after all
- References:
- Why we should have closures after all
- From: Lew
- Re: Why we should (not?) have closures after all
- From: Andreas Leitgeb
- Re: Why we should (not?) have closures after all
- From: Robert Klemme
- Re: Why we should (not?) have closures after all
- From: Andreas Leitgeb
- Re: Why we should (not?) have closures after all
- From: Hendrik Maryns
- Re: Why we should (not?) have closures after all
- From: Andreas Leitgeb
- Re: Why we should (not?) have closures after all
- From: Robert Klemme
- Re: Why we should (not?) have closures after all
- From: Andreas Leitgeb
- Re: Why we should (not?) have closures after all
- From: Patrick May
- Re: Why we should (not?) have closures after all
- From: Lew
- Re: Why we should (not?) have closures after all
- From: Patrick May
- Re: Why we should (not?) have closures after all
- From: Martin Gregorie
- Re: Why we should (not?) have closures after all
- From: Patrick May
- Re: Why we should (not?) have closures after all
- From: Lew
- Re: Why we should (not?) have closures after all
- From: Patrick May
- Re: Why we should (not?) have closures after all
- From: Lew
- Re: Why we should (not?) have closures after all
- From: Patrick May
- Re: Why we should (not?) have closures after all
- From: Andreas Leitgeb
- Re: Why we should (not?) have closures after all
- From: Patrick May
- Why we should have closures after all
- Prev by Date: Handling of a SVG representation with Java's Text Listeners?
- Next by Date: Re: Is there any sense in using final keyword in catch block?
- Previous by thread: Re: Why we should (not?) have closures after all
- Next by thread: Re: Why we should (not?) have closures after all
- Index(es):
Relevant Pages
|