Forum

  • Jan 18
    Re: [eiffel-users] GELINT Tool
    Excellent! I will give it go soon!
  • Jan 18
    Re: [eiffel-users] GELINT Tool
    Please don't hesitate to send me problems when running gelint. The more you will send me, the more I will fix, and the better the tool will be. > But it is interesting to explore this. It will be fun to fold this into > my work as code rather than shelling out. Right now, I am shelling out >
  • Jan 17
    RE: [eiffel-users] Touch of Class - which version
    I didn't follow the earlier part of this discussion but here is the status of the book: There was a first printing which has the full text but was big and heavy. (Springer wanted to do a really good job, in particular use high-quality paper to make sure the color, which I wanted to use,
  • Jan 17
    Re: [eiffel-users] Touch of Class - which version
    Hi Sasa - I'd say my copy makes a good reference for Eiffel - but I'm not an expert in the language, so my opinion probably doesn't hold much weight. :) I can't say if the polikarpova version of the traffic library will have problems with more recent compilers or not (ES 13.11 is the one that's
  • Jan 17
    Re: [eiffel-users] Touch of Class - which version
    On Thu, 16 Jan 2020 20:12:54 -0600 Anthony W wrote: > I have the hard cover 2009 edition. OK. > I have been trying to work through it with one of my daughters, to > introduce her to programming, and it's been basically a non-starter. Hmm, this is very valuable info. >
  • Jan 17
    Re: [eiffel-users] Touch of Class - which version
    On Thu, 16 Jan 2020 20:35:21 -0600 Anthony W wrote: > The zip file at > https://bitbucket.org/nadiapolikarpova/traffic/downloads/ compiles > under ES 13.11 and appears to be the same source (on brief glance) as > the text book. And that's probably not so easy to adjust to
  • Jan 17
    Re: [eiffel-users] Touch of Class - which version
    Correction - The library I downloaded wasn't for the book. The zip file at https://bitbucket.org/nadiapolikarpova/traffic/downloads/ compiles under ES 13.11 and appears to be the same source (on brief glance) as the text book. The git repository I first pulled from ( https://github.com/EiffelSof
  • Jan 17
    Re: [eiffel-users] Touch of Class - which version
    I have the hard cover 2009 edition. I have been trying to work through it with one of my daughters, to introduce her to programming, and it's been basically a non-starter. The code and examples in the book are significantly different than the traffic code you are supposed to download and use.
  • Jan 16
    Re: [eiffel-users] GELINT Tool
    Let me take that back. A prerequisite for the conversion to happen is that there exists a feature in class STRING with that alias (see section 8.27.7 in the ECMA standard). Since this is not the case, then gelint is right to report an error. I can see that EiffelStudio accepts the code and
  • Jan 16
    Re: [eiffel-users] GELINT Tool
    Oh, I see! Yes—that makes sense! BTW—I am just hitting random ECFs to see what pops up from gelint. I hesitate to give too many of these because I don't want to be a squeaky wheel, taking you from other more pressing tasks on your plate. But it is interesting to explore this. It will be fun to
  • Jan 16
    Re: [eiffel-users] GELINT Tool
    Trying it on various libraries. It now seems to be telling a better story. gelint version 19.11.03.1 D:\Users\LJR19\Documents\GitHub\ecfgen>gelint "C:\Program Files\Eiffel Software\EiffelStudio 19.12 GPL\contrib\library\math\decimal\decimal\decimal-safe.ecf" 1>gelint_output.txt Degree 6:
  • Jan 16
    Re: [eiffel-users] GELINT Tool
    story. > > gelint version 19.11.03.1 > > > D:\Users\LJR19\Documents\GitHub\ecfgen>gelint "C:\Program Files\Eiffel > Software\EiffelStudio 19.12 > GPL\contrib\library\math\decimal\decimal\decimal-safe.ecf" > 1>gelint_output.txt > > Degree 6: 0/0/0 0:0:0.014 > Degree 5: 0/0/0 0:0:1.436 >
  • Jan 16
    Re: [eiffel-users] GELINT Tool
    I concur! D:\Users\LJR19\Documents\GitHub\ecfgen>gelint "C:\Program Files\Eiffel Software\EiffelStudio 19.12 GPL\library\vision2\vision2-safe.ecf" 1>gelint_output.txt Degree 6: 0/0/0 0:0:0.056 Degree 5: 0/0/0 0:0:3.127 Degree 4: 0/0/0 0:0:0.968 Degree 3: 0/0/0 0:0:1.400 Total Time: 0/0/0
  • Jan 16
    Re: [eiffel-users] GELINT Tool
    Stable attributes are now supported in the version of gelint in the GitHub repository. This is what I get now when running gelint on EiffelVision: C:\> gelint --target=vision2 %ISE_EIFFEL%\library\vision2\vision2.ecf Degree 6: 0/0/0 0:0:0.044 Degree 5: 0/0/0 0:0:0.215 Degree 4: 0/0/0
  • Jan 16
    Re: [eiffel-users] EiffelStudio & fish shell
    Don't forget to mark it as "Complete" :-) On Wednesday, January 15, 2020 at 11:55:21 PM UTC-5, Saša Janiška wrote: > > On Wed, 15 Jan 2020 22:10:29 +0100 > Jocelyn Fiat wrote: > > > Can you try to use "set -x " also for ISE_EIFFEL and ISE_PLATFORM > > They are required for
  • Jan 16
    Re: [eiffel-users] Touch of Class - which version
    I was not able to find the site/page that I was thinking of, but http://dev.erffel.com/Language_road_map will help. Sent from my iPhone > On Jan 14, 2020, at 6:57 AM, Saša Janiška wrote: > > On Mon, 13 Jan 2020 08:05:53 -0500 > "Gary Smithrud (GMS134)"
  • Jan 16
    Re: [eiffel-users] GELINT Tool
    I think it's now time to try to add support for stable attributes in gelint because I can see that it is used in EiffelVision. -- Eric Bezault mailto:er...@gobosoft.com http://www.gobosoft.com
  • Jan 16
    Re: [eiffel-users] EiffelStudio & fish shell
    On Wed, 15 Jan 2020 22:10:29 +0100 Jocelyn Fiat wrote: > Can you try to use "set -x " also for ISE_EIFFEL and ISE_PLATFORM > They are required for child process, not only to set the PATH That was it!! Now it works. :-D Sincerely, Saša -- The senses are so strong and
  • Jan 16
    Re: [eiffel-users] GELINT Tool
    In order to see whether these internal errors are due to the void-safe mode or not, can you try to run gelint with this command-line option: --capability=void_safety=none -- Eric Bezault mailto:er...@gobosoft.com http://www.gobosoft.com
  • Jan 15
    Re: [eiffel-users] GELINT Tool
    For tomorrow (at your convenience): The gelint tool is reporting a number of errors that I am finding to not make immediate sense. For example, the error below: [VUTA-2] class EV_PIXMAP_IMP (1646,11): the target (of type 'detachable WEL_MEMORY_DC') of the call to feature `select_bitmap' is not
  • Jan 15
    Re: [eiffel-users] GELINT Tool
    Yes, this looks weird. There is not that much experience in using gelint on void-safe code (apart from the code of the Gobo package itself). At work we use gelint on void-unsafe code. One thing that I know for sure is that gelint is failing to consider stable attributes as such. Do you use
  • Jan 15
    Re: [eiffel-users] GELINT Tool
    Thanks for the tip! On Wed, Jan 15, 2020 at 5:34 PM Eric Bezault wrote: > Hi Larry, > > There is one thing that I forgot to mention, since I know that you > are a user of iron. The ECF parser in Gobo (used by gelint) does > not recognize iron packages. So the location
  • Jan 15
    Re: [eiffel-users] GELINT Tool
    I will soon make a new release of Gobo. So you will be able to download such gelint executable compiled with gec, if you want to compare it with the executable that you compiled yourself. -- Eric Bezault mailto:er...@gobosoft.com http://www.gobosoft.com
  • Jan 15
    Re: [eiffel-users] GELINT Tool
    Hi Larry, There is one thing that I forgot to mention, since I know that you are a user of iron. The ECF parser in Gobo (used by gelint) does not recognize iron packages. So the location attribute in elements has to point to ECF filenames that exist on your file system. -- Eric
  • Jan 15
    Re: [eiffel-users] GELINT Tool
    Excellent! I look forward to it!
  • Jan 13
    Selective exportation in Java [closed]

    In an uni project we have to find a java pattern similar to the way Eiffel works. I've been thinking about what could we do and I have no clue.

    We have to find a way in which different classes inherit from the same base class but those classes can only use specific methods from the super class.

    I thought about not implementing some of the methods in the inherited class, but that's not the way, the inherited class shouldn't be able to even call the method.

    Is there any pattern to solve this kind of problem?

  • 2019, Dec 29
    variable is not properly set after renaming into heir

    I know how to fix it (see my solution @bottom) but don't understand why this compilation error occurs, as in my mind, renamed attributes should be created by the Precursor into default_create. Why isn't that so?

    NRJ_ENTITY

    inherit
        ANY
            redefine
                default_create
            end
    
    feature {NONE} -- Initialization
    
        default_create
            do
                create current_day
                create current_month
                create current_year
                Precursor
            end
    
    feature -- Access
    
        current_day,
        current_month,
        current_year: ENERGY_UNIT
    
    end
    

    NRJ_CONSUMER

    inherit
        NRJ_ENTITY
    
    end
    

    NRJ_GENERATOR

    inherit
        NRJ_ENTITY
    
    end
    

    NRJ_GENERATOR_CONSUMER

    inherit
        NRJ_GENERATOR
            rename
                current_day as current_day_generation,
                current_month as current_month_generation,
                current_year as current_year_generation
            redefine
                default_create
            select
                current_day_generation,
                current_month_generation,
                current_year_generation
            end
        NRJ_CONSUMER
            rename
                current_day as current_day_consumption,
                current_month as current_month_consumption,
                current_year as current_year_consumption
            redefine
                default_create
            end
    
    feature {NONE} -- Initialize
    
        default_create
            do
                Precursor {NRJ_GENERATOR}
                Precursor {NRJ_CONSUMER}
            end
    

    end

    Error screenshot

    enter image description here

    Fix into NRJ_GENERATOR_CONSUMER

    default_create
        do
            create current_day_consumption
            create current_month_consumption
            create current_year_consumption
            Precursor {NRJ_CONSUMER}
            Precursor {NRJ_GENERATOR}
        end
    
  • 2019, Dec 19
    How can I run a cursor tree in Eiffel?

    I need a cursor tree and I found CURSOR_TREE and RECURSIVE_CURSOR_TREE classes in EiffelStudio but they are deferred and I don't know how to implement them. Isn'it strange?

  • 2019, Dec 04
    Eiffel: how do I do a system call?

    Id like to uncompress a file with bzip2 myFile.bz2 which class do I have to use for that?

    I tried to find it into base kernel documentation which made the most sense for me and didn't find it

  • 2019, Dec 04
    check with no content at runtime without assertions

    As far as I understood in Eiffel, the following code without assertions fails if the statement returns False

    check
        i_m_alive: i.alive
    then
        do_nothing
    end
    

    Maybe I'm badly using it but sometimes I'd like to check it without doing anything else.

    • What is the exact behavior of this statement with and without assertions?
    • Should I use a raise with an if statement?
    • I sometimes try to add an else statement to the check ... then but its not implemented I'm sure for a reason, probably because there is no alternative as an exception is raised in case the statement returns True

    Specially on EWF (Eiffel Web Framework) the only way I see to report an error and treat it is either to write into logs or sending the details to the referrer with some details which are sometimes not adequate to send to the user. Sending an email to the administrator is also a possiblity... I'm a bit lost, but know that the raise and Exception mecanisms is not the way Eiffel recommends to treat errors.

    I'll dig further into the available documentation about that but think as me the TL;DR will be happy to have a more concise answer or more points of view about that.

  • 2019, Dec 03
    How to declare an INTEGER_64 from number?

    How to declare an INTEGER_64 from a declared number?

    ("3000000000").to_integer_64

    is the only way I found

  • 2019, Dec 02
    twin vs deep_twin, is_equal vs is_deep_equal

    What is the difference between twin and deep_twin which implies (and ensures) the difference between is_equal and is_deep_equal in eiffel?

  • 2019, Nov 23
    How to test objects of formal generic types for equality in Eiffel?

    I should test for equality two generic attributes like

    a, b: G
    ...
    Result := a.is_equal (b)
    

    but VUTA (target rule validity) says "separate target of the Object_call is not controlled". What can I do?

  • 2019, Nov 17
    How to Swap Value in Eiffel Programming Language?

    I am defining like this in eiffel to swap the value. We cannot use the way we define in c++.

     swap(x,y):INTEGER
             do
                x;y := y;x
           end
    

    How to define functions in Eiffel? I want to define heap sort but it is showing some error can someone help me clear my doubt about function.

     heapsort(array,N):INTEGER  -- heap_sort
                do
                    heap_size : INTEGER
                    heap_size := N
    
                    build(array,N)
    
                    from i := N until i >=2 loop
    
                        swap(array(1), array(i))
                        heap_size := heap_size-1
                        heapify(array,1,heap_size-1)
    
                    end
                end
    
  • 2019, Nov 17
    Error handling in Eiffel and Rescue clause

    Is writing one rescue clause at the end of a program to end the program in Eiffel enough to handle exceptions such as pre, postconditions or invariant violations in any of the routines written in the program? Or should I write rescue clause for every function having pre and postconditions to handle exceptions?

    I have read Eiffel documentation on error handling but I couldn't figure out.

  • 2019, Nov 15
    FIle handling in Eiffel

    Given a file input.txt, which consists of a number of elements in arrays and elements in the arrays, I should read the data and copy it to arrays in Eiffel. For example, for

    3 
    3 4 5
    2 3 1
    

    I should get len = 3, a1 = {3,4,5}, a2 = {2,3,1}.

    I have tried the following but it was not successful

    take_input
            -- Read user's input.
        local
            input: PLAIN_TEXT_FILE
            output: PLAIN_TEXT_FILE
            itr: INTEGER
        do
            create input.make_open_read ("input.txt")
            input.read_integer
            len := input.last_integer
            create output.make_open_write ("output.txt")
            create num.make_filled (0, 1, len)
            create rem.make_filled (0, 1, len)
            from
                input.start
                input.read_integer
                itr := 0
            until
                input.off
            loop
                itr := itr + 1
                if itr <= len then
                    num [itr] := input.last_integer
                    input.read_integer
                else
                    rem [itr - len] := input.last_integer
                    input.read_integer
                end
            end
            input.close
        end
    

    Here Is there any way I can continously read the inputs rather than again starting from the Begginning of the file?

  • 2019, Nov 15
    How to send an email with eiffel kernel library

    How can a mail be sent in eiffel with kernel library? which class to use?

  • 2019, Nov 14
    Some ways to sort a collection of comparables in eiffel

    Which library of the kernel should I use to sort a collection in eiffel?

    where can I find an example of sort? are the tipical bubble sort, etc available?

    Any sorter with agent would be very useful too to avoid having to do it with a comparable which is not implemented for example with PATH class

  • 2019, Nov 13
    Why is LINKED_SET unable to compare objects?

    As I'd like to know if some object is into a LINKED_SET to prune it in my context, I'm unable to compare it as an object instead of its reference.

    changeable_comparison_criterion: BOOLEAN
            -- May `object_comparison' be changed?
            -- (Answer: only if set empty; otherwise insertions might
            -- introduce duplicates, destroying the set property.)
        do
            Result := is_empty
        ensure then
            only_on_empty: Result = is_empty
        end
    

    Into the SET class (as above) it seems that its not possible to change a set to compare_objects. So my questions are:

    1. What is the semantic of not being able to compare objects into a SET
    2. If my choice of LINKED_SET is wrong by misunderstanding of its semantic, how should I do for having a unique items collection based on object comparison and then being able to prune an item again based on object comparison again
  • 2019, Oct 16
    explicit creation type not conforming to type of target

    I really don't understand as it seems to me the basics of type conformance. I have a Creation instruction lists explicit creation type which does not conform to type of target on create {JANITZA_DEVICE} l_device.make_from_file_path (a_file_path) with eiffel studio 19.5 enterprise.

    class schema

    SMA_INVERTER_MANAGER_CSV

    class
        SMA_INVERTER_MANAGER_CSV
    
    inherit
        SUNSPEC_DEVICE_CSV[SMA_INVERTER_MANAGER_DEVICE]
    
    create
        make
    

    SUNSPEC_DEVICE_CSV

    deferred class
        SUNSPEC_DEVICE_CSV[G -> SUNSPEC_DEVICE create make_from_file_path end]
    
    inherit
        CONSUMPTION_SECTOR_CSV[G]
            redefine
                process_file,
                set_header_csv
            end
    
    feature --
    
        process_file (a_file_path: PATH)
            require else
                attached a_file_path.entry
                attached consumption_sector
            local
                l_device: like devices.item
            do
                check
                    attached_consumption_sector: attached consumption_sector
                then
                    if is_valid_file_path (a_file_path) then
                        if attached a_file_path.utf_8_name.has_substring ("janitza_UMG604") then
                            create {JANITZA_DEVICE} l_device.make_from_file_path (a_file_path) -- The compiler doesn't agree!
                        else
                            create l_device.make_from_file_path (a_file_path)
                        end
                        l_device.load_measuring_point (create_measuring_points, measuring_point_db_service, consumption_sector)
                        devices.extend (l_device)
                        Precursor (a_file_path) -- load measure_units from csv_row
                        devices.wipe_out
                    end
                end
            ensure then
                devices.is_empty
            end
    

    CONSUMPTION_SECTOR_CSV[G]

    deferred class
        CONSUMPTION_SECTOR_CSV[G -> MEASURING_POINT_DEVICE]
    
    feature -- Access
    
        devices: LINKED_SET[G]
    

    SUNSPEC_DEVICE

    class
        SUNSPEC_DEVICE
    
    inherit
        MEASURING_POINT_DEVICE
            redefine
                default_create,
                set_measuring_point,
                out
            select
                serial
            end
    
        MODBUS_DEVICE
            rename
                serial as modbus_serial,
                set_serial as set_modbus_serial
            undefine
                make
            redefine
                default_create,
                make_from_file_path,
                name_from_file_path,
                out
            select
                set_modbus_serial
            end
    
    create
        make_from_file_path
    

    JANITZA_DEVICE

    class
        JANITZA_DEVICE
    
    inherit
        SUNSPEC_DEVICE
            redefine
                set_measure_units,
                name_from_file_path
            end
    
    create
        make_from_file_path
    
  • 2019, Oct 15
    how to merge an attribute in multi-inheritence

    Repeatedly inheriting from 2 classes having the same parent, I fall into the classic case of inheriting 2 times of the same attribute. I'd like to merge the 2 attributes into one and tried to do it with an undefine, but it gets me a compile error. The other solution I see is renaming the attribute from one of both parents, but as I understand each instance of my D class would have an useless attribute which is not what I want...

    Error: Undefine subclause lists name of frozen feature or attribute or C external. What to do: unless you can change the status of the feature in the parent, remove its name from Undefine subclause since it cannot be undefined.

    How to merge 2 attributes from repeatedly inherited classes

    class A
        serial: STRING
    
    end -- class A
    
    class B
    
    inherit
        A
    
    end -- class B
    
    
    class C
    
    inherit
        A
    
    end -- class C
    
    
    class D
    
    inherit
        B
            undefine 
                serial -- error seems to appear here in that case
            end
        C
    
    end -- class D
    
  • 2019, Oct 15
    How to specify when giving a generic parameter that it should implement some specific creation method?

    How to specify when giving a generic parameter that it should implement some specific creation method? as LIST[G -> create make end] doesn't work :-(

    class diagram

    In my particular case, * SMA_INVERTER_MANAGER_CSV has inherited from CONSUMPTION_SECTOR_MODBUS_DEVICE_CSVa list of devices as devices: LINKED_SET[G] as G -> MEASURING_POINT_MODBUS_DEVICE create make_from_file_path end.

    I'd like the SMA_INVERTER_MANAGER_CSV class to be able into devices: LINKED_SET[G] to be able to have either JANITZA_DEVICE, SUNSPEC_DEVICE, ABB_DEVICE, etc. Giving the generic parameter as MEASURING_POINT_MODBUS_DEVICE seems to come out of a sense, but how do I specify that I'd like the creation method to be make_from_file_path

    Hope the description is sufficient to understand, refactoring I think this question is linked -> explicit creation type not conforming to type of target

    The only workaround for the moment I found working for the moment is

    class
        SMA_INVERTER_MANAGER_CSV
    
    inherit
        CONSUMPTION_SECTOR_MODBUS_DEVICE_CSV[SUNSPEC_DEVICE]
    
    create
        make
    
    
    end
    

    but I'd like it to be

    class
        SMA_INVERTER_MANAGER_CSV
    
    inherit
        CONSUMPTION_SECTOR_MODBUS_DEVICE_CSV[MEASURING_POINT_MODBUS_DEVICE]
    
    create
        make
    
    
    end
    

    which would generate a conformance problem because MEASURING_POINT_MODBUS_DEVICE generic parameter doesn't specify make_from_file_path as creation procedure as its deferred

  • 2019, Oct 11
    How do I get a true value when using object_comparison on an empty linked list in my post condition?

    I have an assignment that requires me to create an empty linked list key: LINKED_LIST [KEY], another linked list data_items_1: LINKED_LIST [DATA1] and a hash table data_items_2: HASH_TABLE [DATA2, KEY] in the constructor. The post condition that my professor put was

    object_equality_for_keys: keys.object_comparison
    object_equality_for_data_items_1: data_items_1.object_comparison
    object_equality_for_data_items_2: data_items_2.object_comparison
    

    When I run the program I get a contract violation. In the debugger it's always pointing to this line of code and I'm not sure why. What is the purpose of this post condition and how do I not violate this contract? Error Message

  • 2019, Sep 29
    How do I use an across loop in post condition to compare an old array and new array at certain indices?

    I have a method that shifts all the items, in an array, to the left by one position. In my post condition I need to ensure that my items have shifted to the left by one. I have already compared the first element of the old array to the last element of the new array. How do i across loop through the old array from 2 until count, loop through the new array from 1 until count-1 and compare them? This is my implementation so far.

            items_shifted:
                        old array.deep_twin[1] ~ array[array.count]
                            and
                        across 2 |..| (old array.deep_twin.count) as i_twin all
                            across 1 |..| (array.count-1) as i_orig  all
                                i_twin.item ~ i_orig.item
                                end
                            end
    
    
    
        end
    

    I expected the result to be true but instead I get a contract violation pointing to this post condition. I have tested the method out manually by printing out the array before and after the method and I get the expected result.

  • 2019, Aug 30
    semantic of having to declare an attached local into detachable attribute with mandatory check

    As far as I understood the check with then is mandatory.

    So what is the semantic of having to declare a local to avoid compiling error (object could be void)?

    detachable dog: DOG
    
    take_a_walk
        do
            check
                attached_dog: attached dog as l_dog
            then
                leash (l_dog) -- why not just leash (dog)?
                walk
            end
        end     
    
  • 2019, Aug 28
    why is that I can't create an instance_free feature in a deferred class?

    I'd like to create a class with both an instance_free (ensure class) feature and a deferred one.

    why is that I can't call an instance_free feature in a deferred class but only on a descendant?

    Don't understand the logic of that... is there for compiling reasons? or any sense I don't see? Where am I wrong with my logic?

  • 2019, Aug 28
    Is the rescue clause being called on descendent redefinition?

    Didn't find the answer on this doc, is the rescue clause called when redefining a feature?

    Class A

    class A
    
    feature -- 
    
        process
            do
                do_stuff
            rescue
                on_fail
            end
    end -- class
    

    Class B

    class B
    
    inherit
        A
            redefine
                process
            end
    
    feature -- 
    
        process
            do
                do_other_stuff -- do I have to call the rescue too?
            end
    end -- class
    
  • 2019, Aug 28
    Eiffel: a way to call precursor redefined feature on another function

    I'm looking for a way to call Precursor on another feature. The context is that I redefine a routine calling another heir's feature that calls mine, and I'd like to call it explicitly. Is there a way to do something such as in java Precursor.feature_a.

    If not, the only alternative I find is to write a feature_a_implementation and call it from redefined feature. Is there a particular reason not to have this mechanism? The consequences of doing that would be to define 2 times the contract of feature_a into feature_a and feature_a_implementation

  • 2019, Aug 27
    Eiffel: a way to get target and project name @runtime

    Is there a way to get the project name and target at execution time or is it not stored into executable?

  • 2019, Aug 22
    Eiffel: best way to create a redefinable "constant"

    As mentioned on this question, there is no way to define a constant which I can redefine into a descendant.

    In many of my cases, I'd like to have a constant which I can redefine. The alternatives I see to avoid a creation on each consultation which doesn't make sense would be

    That's not doable

    class A
    
    feature -- Access
    
        Default_value: STRING = "some A value"
    
    end -- Class
    
    
    class B
    
    inherit
        B
            redefine
                Default_value
            end
    
    feature -- Access
    
        Default_value: STRING = "some B value"
    
    end -- Class
    

    Alternative with once instance_free

    class A
    
    feature -- Access
    
        Default_value: STRING
            once
                Result := "some A value"
            ensure
                instance_free: class
            end
    
    end -- Class
    
    
    class B
    
    inherit
        B
            redefine
                Default_value
            end
    
    feature -- Access
    
        Default_value: STRING
            once
                Result := "some B value"
            ensure
                instance_free: class
            end
    
    end -- Class
    

    As far as I understand, the once wouldn't be created with B value as the A class value would be taken

    Alternative with attribute

    class A
    
    feature -- Access
    
        Default_value: STRING
            attribute
                Result := "some A value"
            ensure
                instance_free: class
            end
    
    end -- Class
    
    
    class B
    
    inherit
        B
            redefine
                Default_value
            end
    
    feature -- Access
    
        Default_value: STRING
            attribute
                Result := "some B value"
            ensure
                instance_free: class
            end
    
    end -- Class
    

    Would it be the only and good practice to do it?

  • 2019, Jul 24
    Eiffel: regular expressions how to do grouping

    I'd like to do grouping of regular expressions with eiffel. How do I do something like

    l_reg.compile ("^([0-9]{3}) (rabbit[0-9]).*")
    l_groups := l_reg.groups ("123 rabbit1")
    my_first_rabbit := l_groups.at (2)
    

    Didn't find any example on groups, LX_DFA_REGULAR_EXPRESSION class and other googlings

  • 2019, Jul 19
    Eiffel: percent character into a string

    How do I concatenate a percent % string to a string?

    as either do not work

    s := "%%" + s + "%" 
    

    I know its a special character but don't afford it neither do I find the doc...

    UPDATE

    The answer was one of my attempts, but it could stay an issue of the compiler/editor. After putting the example into the same feature, compiling, and replacing the old code the compiler did not complain anymore, but still stays as syntax coloration strange

    enter image description here

  • 2019, Jul 19
    Eiffel: syntax error on multiple Generic constraint

    As per this documentation, I'm trying to constrain a Generic parameter to 2 classes and need a default_create creation procedure call in my implementation.

    I'm getting a Syntax error from compiler on the select clause. Why is that so?

    I thought first that calling default_create will call the G one which could be a merge/renaming/etc. but seems that on that level I have to call either one of both or both renamed which makes sense for me. But why does this syntax fail?

    The context and my code is following:

    deferred class
        IDENTIFIABLE_CASH[G -> {IDENTIFIABLE[ANY],
                                DB_ENTITY select default_create end} create default_create end]
    
    inherit
        DB_SERVICE_CASH[G]
    
    
    feature -- Access
    
        cash_from_identifier (an_identifier: like {IDENTIFIABLE_DB_ENTITY[ANY]}.identifier): G
                -- Returns firt entity found like given an_identifier (like operator is used)
            local
                l_qry: COMPOSED_SQL_QUERY
            do
                across
                    cash is l_item
                loop
                    if l_item.identifier.is_equal(an_identifier) then
                        Result := l_item
                    end
                end
                if not attached Result then
                    create l_qry.make (item_prototype)
                    l_qry.add_constraint (create {FIELD_CONSTRAINT}.make (Void, identifier_db_column_name, {CONSTRAINT}.Like_operator, an_identifier))
                    load_entities (l_qry)
                    if items.count > 0 then
                        Result := items.first
                    else
                        create Result
                        check
                            item_not_found: False
                        end
                    end
    
                    cash.extend (Result)
                end
            end
    
  • 2019, Jul 03
    Eiffel: Where can I find a reference with common features lists?

    Am looking for typical

    feature {NONE} -- Initialization (semantic)
    feature -- Status Settings (semantic)
    .....
    

    Where can I find that list with semantic?

    Didn't find it into ECMA

  • 2019, Jun 29
    Eiffel: best way to compare types without getting a catcall

    Got a Catcall trying to compare 2 types, how could I do that avoiding passing through another not dedicated method (like to string, class_id or stuff like that)?

    enter image description here

    SIT_UTIL

        class_name_lowercase (a_string: STRING): STRING
                -- a copy lowercased and pruned from preceding '!'
            do
                Result := a_string
                if Result.index_of('!', 1) = 1 then
                    Result := Result.substring (2, Result.count)
                    Result.to_lower
                else
                    Result := Result.as_lower
                end
            ensure
                instance_free: class
            end
    

    CLIENT_CLASS

        relationship_from_secondary_type_equal (a_type: like relationships.item.secondary_type): detachable like relationships.item
                -- Returns first instance of found relationship secondary type which equals given one
            do
                across
                    relationships as l_rel
                until
                    Result /= Void
                loop
    --              if attached (a_type / l_rel.item.secondary_type) then -- Don't want conformance but equality
    
    --              if attached (a_type.is_equal (l_rel.item.secondary_type)) then -- tried but as is_equal needs a like Current => Catcall
    --              if attached (a_type.equal (a_type, l_rel.item.secondary_type)) then -- Catcall because b signature is like a
                    if {SIT_UTIL}.class_name_lowercase (a_type).is_equal({SIT_UTIL}.class_name_lowercase (l_rel.item.secondary_type)) then
                        Result := l_rel.item
                    end
                end
                check
                    not_found_relationship: Result /= Void
                end
            end
    
  • See more ...