From: Michal Kleczek on
Tom Anderson wrote:

> On Mon, 28 Sep 2009, Michal Kleczek wrote:
>
>> Roedy Green wrote:
>>> Think how many times you have wondered if a variable is measured in
>>> seconds, ms, or ns. Here would be a formal way to specify and check
>>> your assumption was correct.
>
> Gosling keeps talking about adding this to java.
>
>> That is not so easy to make it right. Read for example:
>> http://research.sun.com/projects/plrg/Publications/p109-allen.pdf
>
> If you want to be able to have arbitrary units which can be checked at
> compile-time, sure, you need to add difficult stuff to the language. If
> you can satisfy yourself with a fixed set of units, or runtime-only
> checking, you can do it in java now.

Fixed set of units is problematic because it is... fixed :)
Runtime-only checking is actually no checking at all (who cares if a bug
manifests itself in an IllegalArgumentException or otherwise?)
To be honest - seeing various Java language change proposals for 1.7 - I am
against all of them. The ones I think are needed are changes extending the
type system so that more bugs can be eliminated statically - but there are
none...

--
Michal
From: markspace on
Michal Kleczek wrote:
> The ones I think are needed are changes extending the
> type system so that more bugs can be eliminated statically


What sort of changes would you advocate?
From: Michal Kleczek on
markspace wrote:

> Michal Kleczek wrote:
>> The ones I think are needed are changes extending the
>> type system so that more bugs can be eliminated statically
>
>
> What sort of changes would you advocate?

Hmm... It is more like a wishlist:

1. Option types
Whatever the name of the feature - I'd like to be able to mark a variable as
not null (I would actually prefer to mark variables as nullable but that
would not be backwards compatible). And I don't think adnotations are
enough.
2. First class type parameters ( "new T()" anybody? :) )
3. Metaclasses as described in the publication I gave link to would be
useful

Just from the top of my head...

--
Michal
From: Lew on
Michal Kleczek wrote:
> 2. First class type parameters ( "new T()" anybody? :) )

No, thanks.

--
Lew

From: Alessio Stalla on
On Sep 29, 9:40 am, "Kenneth P. Turvey" <evotur...(a)gmail.com> wrote:
> On Mon, 28 Sep 2009 23:25:39 -0700, Kevin McMurtrie wrote:
> > In article <alpine.DEB.1.10.0909282318480.8...(a)urchin.earth.li>,
> >  Tom Anderson <t...(a)urchin.earth.li> wrote:
>
> >> On Mon, 28 Sep 2009, Michal Kleczek wrote:
>
> >> > Roedy Green wrote:
>
> >> >> Consider a program that uses a mixture of 10-character and 13-digit
> >> >> ISBN numbers (International Standard Book Number). From Java's point
> >> >> of view, they are all Strings.
>
> >> >> It would be nice if there were some mechanism to label Strings with
> >> >> a light-weight type, probably a purely compile-time concept, similar
> >> >> to generics.  You would then label some string vars as ISBN13 and
> >> >> some as ISBN10, and similarly parameters to methods. Then the
> >> >> compiler could detect an improper passing of in ISBN13 string to an
> >> >> ISBN10 parameter.
>
> >> >> An extension of this idea is units of measure, so that you could not
> >> >> pass a cm variable to an inch parameter (though possibly you could
> >> >> with an automatic conversion applied).
>
> >> >> Think how many times you have wondered if a variable is measured in
> >> >> seconds, ms, or ns. Here would be a formal way to specify and check
> >> >> your assumption was correct.
>
> >> Gosling keeps talking about adding this to java.
>
> >> > That is not so easy to make it right. Read for example:
> >> >http://research.sun.com/projects/plrg/Publications/p109-allen.pdf
>
> >> If you want to be able to have arbitrary units which can be checked at
> >> compile-time, sure, you need to add difficult stuff to the language. If
> >> you can satisfy yourself with a fixed set of units, or runtime-only
> >> checking, you can do it in java now.
>
> >> tom
>
> > Hopefully nobody 'solves' this by adding Generics to Strings.  Java's
> > syntax is already going off the deep end.  (And yet the simple things
> > like unsigned math and arrays of contiguous Object data are dismissed as
> > not worth the effort.)
>
> Both of those are real annoyances... I've got one more though, closures.  
> Anonymous classes are ugly when unneeded.

The problem with closures is that there's not enough consensus on how
they should be done. The most popular proposal, "BGGA", has some
idiosyncracies that make it work in a subtly different way than how
closures work in most other languages that have them. I'd love to have
closures in Java, but you have to think very carefully before adding
something that big to a language.


First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13
Prev: Putting passwords in a properties file?
Next: Interview