Hello David,
the answers to your questions see below.
Regards
Helmut
dlebansais wrote:
> In my opinion, #7 is a much bigger issue than #1. However, I don't
> work with expanded types much, only with the basic ones. You probably
> have problems with them that I never meet.
>
> #7 on the other hand affects most Eiffel programmers since ARRAY is a
> pretty common construct in programs.
Agreed. Many developers are not affected by #1, because they don't use
expanded types. But nearly all need ARRAYs. Therefore the priority it clear.
>
> But let's address #1.
>
>> 1. All expanded types must have default_create available for
>> creation
>
>> I don't like the asymmetry between expanded and reference types and
>> think that especially rule #1 will make non trivial expanded types
>> very clumsy.
>
> The ability for a compiler to build the initialized value of an
> expanded type is in my opinion critical for basic types (INTEGER and
> such). I've been working with uninitialized integers in C++ for years
> and hated it every single time.
>
> In the declaration
>
> i: INTEGER
>
> the ability for i to acquire a default value before any code having
> access to it is executed is in my opinion critical. If we don't agree
> on this, I don't think our opinions can be reconciled. ;)
There is no disagreement on this. All variables (local variables and
attributes have to be initialized before its use. That is critical to
high quality software. Regardless whether they represent expanded or
reference type objects.
>
> Starting from this, it seems straightforward logic to extend the
> mechanism to all expanded types and attached reference, for the sake
> of never leaving anything uninitialized. Detachable reference types
> are just another form of expanded data, with initialized value
> 'void'.
ok.
>
> When you speak of "non-trivial expanded types" I assume you're
> talking about classes containing references, leading to some
> complexity if there are recursive references for instance.
Exactly. I mean expanded type objects which do not have a reasonable
default value. Everybody agrees that many reference types don't have a
reasonable default value. But many expanded types don't have a
reasonable default value either. Just the `trivial' ones, i.e numbers
like INTEGERs and REALs or BOOLEANs.
>
> The problem is that if the programmer can't expect an expanded type
> to be initialized with a definite, fixed value, it might as well be
> uninitialized.
This shall be avoided. A consequence of lack of initialization is in
many cases a violated invariant.
>
> In the declaration
>
> an_expanded_variable: AN_EXPANDED_CLASS
>
> what additional syntax do you suggest that would let
> an_expanded_variable take different value based of some parameter?
> There is no need for one, you already have it with the call
>
> an_expanded_variable.make(<insert parameters here>)
The mechanism I have in mind is quite simple. If the object has a
reasonable default value, the designer of the class can provide the
argumentless `default_create' for creation. With that the compiler can
initialize all attributes and local variables before they can be accessed.
If there is no reasonable default value, the user have to create (i.e.
initialize) it explicitly with the Eiffel construct
create an_expanded_variable.make(arg1,arg2,...)
If the `create' is missing the compiler shall raise a validation error
at compile time. With that rule it can be guaranteed that at runtime you
never access an uninitialized variable or attribute.
>
> The only requirement being that the class invariant stands at the
> time of the call, i.e. the class has a default creation mechanism.
>
> I can see two ways out of this situation: . Allow explicitely
> uninitialized expanded types. For instance with a new 'uninitialized'
> keyword (or some other notation as name clashes is another of our
> concerns) These types would allow deferred initialization to occur at
> the first call, permitted only to a creation procedure, and would not
> check the class invariant until the creation procedure ends.
I don't understand what you mean by that. I don't want uninitialized
expanded type objects. Expanded type objects have to be initialized
either explicitly (by a creation call) or implicitly (by letting the
compiler make the creation call with `default_create').
>
> . Require default_create for all expanded and attached reference
> types, at the expense of clean design. Forcing programmers to use
> default values that don't make much sense, or to lessen class
> invariant requirements to allow for these unnatural values that are
> there only for initialization sake.
That is exactly my concern with the current ECMA status on expanded types.
>
> I can see why default_create seems a better choice to keep the
> language simple, since you need it anyway. Also, there might be some
> concern at the implementation level when handling uninitialized
> variables. Every call would have to check if the object is
> initialized.
This is not necessary. It can safely be checked at compile time.
Therefore there is no degradation of performance.
>
> I think that in your code you pay the price for copy semantic by
> having to use clumsy design. Isn't it just a tradeoff?
If the current ECMA status does not change, non-trivial expanded types
won't be used. That is the consequence.
>
> David Le Bansais
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>