bugLiberty Eiffel - Bugs: bug #43266, self-initilizing attributes

 
 

bug #43266: self-initilizing attributes

Submitter:  Raphael Mack <ramack>
Submitted:  Sat 20 Sep 2014 10:30:41 PM UTC
   
 
Category:  SmartEiffel Severity:  2 - Minor
Priority:  * 5 - Normal Status:  None
Assigned to:  ramack Open/Closed:  Open
Release:  None Fixed Release:  None
Planned Release:  dennis
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 14 Nov 2023 09:08:11 AM UTC, comment #3: 

I've started to have a look at this, founding a couple of interesting tests at test/language/unclassified/test_attribute02.e and test/language/unclassified/test_attribute03.e

Currently they "obviously" fails. So I tried using ISE online compiler at https://www.eiffel.org/codeboard with this small code

class    APPLICATION
create     make
feature {NONE} -- Initialization
    make
        do
            print ("Hello Eiffel World!%N"+e.out)
        end
    e: INTEGER
        attribute
        Result:= 42
        ensure Result>0
        end
end

ISE compiler answered with this warning:

Warning code: VWAB

Warning: attribute body is never executed because the type of the attribute is self-initializing (i.e. expanded or detachable).

What to do: remove any instructions in the attribute body.

When running the above example you get:

======================
Hello Eiffel World!
0
======================

Showing that the attribute body is actually not executed.
So at least this means that at least for expanded attributes we may "safely" consider this a non-bug.

The issue would be much different whenever e is a reference object, such as a LINKED_LIST, like this:

class    APPLICATION
create     make
feature {NONE} -- Initialization
    make
        do
            -- Add your code here
            print ("Hello Eiffel World!%N"+e.out)
        end
    e: ARRAY[INTEGER]
        attribute
        Result:= <<1,2,42>>
        end
end

that gets:



    application.e

Hello Eiffel World!
ARRAY [INTEGER_32] [0x7F405BDFE658]
  area: SPECIAL [INTEGER_32] [0x7F405BDFE628]
    -- begin special object --
        0: INTEGER_32 = 1
        1: INTEGER_32 = 2
        2: INTEGER_32 = 42
    -- end special object --
  object_comparison: BOOLEAN = False
  upper: INTEGER_32 = 3
  lower: INTEGER_32 = 1


Paolo Redaelli <Tybor>
Group administrator
Mon 20 Oct 2014 09:28:17 AM UTC, comment #2: 

I think it needs a non-negligible work. Postpone to curtiss.

Cyril Adrian <cadrian>
Group administrator
Sat 20 Sep 2014 10:57:29 PM UTC, comment #1: 

it seems useful to add a new type of RUN_FEATURE for self-initializing attributes and to disallow normal attributes to have contracts.

Raphael Mack <ramack>
Group administrator
Sat 20 Sep 2014 10:30:41 PM UTC, original submission:  

Using the new 'attribute' keyword to define instance variables allows the definition of a pre- and postcondition. These are only relevant for self-initialization, which is currently not implemented.
Also it seems, that the postcondition is currently not check correctly.

Also necessary to test: rescure clause, local variables, contracts and body only executed for first access.

BTW: for self-initialization with a constant this can be optimized to do the init at the end of all creation procedures.

Raphael Mack <ramack>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #32316:  attributes.e added by ramack (676B - text/x-eiffel - attribute axample for this feature (attached here, as removed from git repo until curtiss))

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by Tybor (Posted a comment)
  • -email is unavailable- added by ramack (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-09-04 ramack Planned Releasecurtiss dennis
    2014-10-24 ramack Attached File- Added attributes.e, #32316
    2014-10-20 cadrian Planned Releasebell curtiss
    2014-09-20 ramack Assigned toNone ramack

    Back to the top

    Powered by Savane 3.13-b921.
    Corresponding source code