Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #34304

Re: hashtables syntax

Path csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Steven Simpson <ss@my.domain.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: hashtables syntax
Date Mon, 16 May 2016 15:51:59 +0100
Organization A noiseless patient Spider
Lines 46
Message-ID <fd3p0d-s27.ln1@s.simpson148.btinternet.com> (permalink)
References <nh954m$bu8$1@reader1.panix.com> <nh9n7r$ira$1@dont-email.me> <338d0b8c-9a5e-ccc0-9a5c-792c870f84bf@mrbrklyn.com> <nhcbrv$7qk$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
Injection-Info mx02.eternal-september.org; posting-host="0f928dddd1117028fbe6efb26c856d65"; logging-data="18257"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Bfjmyr7oTwSqBtuCCEW73lURlA+IS1Pc="
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2
In-Reply-To <nhcbrv$7qk$1@dont-email.me>
Cancel-Lock sha1:qPF2Yl/prdtc6wLIaS3aCuCbv+g=
Xref csiph.com comp.lang.java.programmer:34304

Show key headers only | View raw


On 16/05/16 12:48, Eric Sosman wrote:
> On 5/16/2016 1:26 AM, ruben safir wrote:
>> Gotchya, but it seems inconsistent.
>>
>>
>> why not like
>>
>> HashMap<> function = new HashMap<String, Type[]>
>
>     With what is this "inconsistent?"  I'm not seeing your point.
>
>     The types must be specified on one side or the other; Java
> decided to insist that they appear on the left.  Java *could*
> have chosen to have them on the right (I suppose, but there may
> be considerations I'm unaware of), but it chose the left.  Shrug.

It would arguably be inappropriate to put the type information 'on the 
right' in the the OP's case, where the declaration of the reference is 
separate from its assignment.  The generic parameters would be visible 
only within the static initializer, while the declaration is visible 
throughout.  Imagine:

    private static HashMap<> functions;

     static { // initialize function types
         functions = new HashMap<String, Type[]>();

Compile-time checking of calls like functions.get(20) would have to 
inspect the static initializer, rather than the declaration.  Also, I 
expect it would be more complex to inspect situations like this:

    private static HashMap<> functions;

    // at some point
    functions = new HashMap<String, Type[]>();

    // later
    functions = new HashMap<Integer, String>();

The declaration acts as a kind of rendezvous point between users and 
providers of 'function', so it makes sense to propagate type information 
out from that point.

-- 
ss at comp dot lancs dot ac dot uk

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

hashtables syntax Popping mad <rainbow@colition.gov> - 2016-05-15 06:31 +0000
  Re: hashtables syntax Lew <lewbloch@gmail.com> - 2016-05-14 23:52 -0700
    Re: hashtables syntax Popping mad <rainbow@colition.gov> - 2016-05-15 10:23 +0000
      Re: hashtables syntax Lew <lewbloch@gmail.com> - 2016-05-15 09:33 -0700
        Re: hashtables syntax Lew <lewbloch@gmail.com> - 2016-05-15 09:35 -0700
      Re: hashtables syntax Eric Douglas <e.d.programmer@gmail.com> - 2016-05-16 06:10 -0700
  Re: hashtables syntax Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-15 07:44 -0400
    Re: hashtables syntax ruben safir <ruben@mrbrklyn.com> - 2016-05-16 01:26 -0400
      Re: hashtables syntax Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-16 07:48 -0400
        Re: hashtables syntax Steven Simpson <ss@my.domain.invalid> - 2016-05-16 15:51 +0100
          Re: hashtables syntax Steven Simpson <ss@my.domain.invalid> - 2016-05-16 22:35 +0100
      Re: hashtables syntax Lew <lewbloch@gmail.com> - 2016-05-16 16:10 -0700
  Re: hashtables syntax Andreas Leitgeb <avl@logic.at> - 2016-05-15 13:43 +0000
  Re: hashtables syntax Roedy Green <see_website@mindprod.com.invalid> - 2016-05-20 18:00 -0700

csiph-web