Forum

  • Dec 04
    Re: [eiffel-users] Re: Editor Tool Completely GONE!
    This worked. I had it happen in 19.05 as well, so I was out of options other than I thought to uninstall-and-reinstall. Thankfully, deleting those files and wiping out EIFGENs did the trick. I had to delete the EIFGENs because there were some stuck file handles.
  • 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

  • Dec 04
    Re: [eiffel-users] linux OS call, unable to get any working function for command having a pipe. Dummy ex. : `/usr/bin/md5sum /etc/hosts | cut -f1 -d' '`
    Hi all, a bit of noise too but useful for some lets hope, TL;DR: put the whole path of a command, even for the shell to use, not "sh" but "/bin/sh" or "/bin/bash" if you prefer I had a hard time discovering that using apache libfgi the environment is different... so the shell should be with
  • 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.

  • Dec 04
    Re: [eiffel-users] linux OS call, unable to get any working function for command having a pipe. Dummy ex. : `/usr/bin/md5sum /etc/hosts | cut -f1 -d' '`
    Sorry for the noise, it was my code which had an error, and interpreted it as it wasn't waiting :$ the function I posted is working, even tested with piped_command_result ("sleep 20") Thx for your precious help! On Tuesday, December 3, 2019 at 10:43:25 PM UTC, Gachoud Philippe wrote: > >
  • Dec 04
    Re: [eiffel-users] Re: Editor Tool Completely GONE!
    Hi On Windows, check the files under %LOCALAPPDATA%\Eiffel Software\.es\19.05 On Linux, it should be under ~/.es/19.05 and remove the docking files to reset the EiffelStudio layout. On Wed, Dec 4, 2019 at 8:17 AM Richard wrote: > Not a solution but a note: > I had a
  • Dec 04
    Re: Editor Tool Completely GONE!
    Not a solution but a note: I had a similar situation with EiffelBuild in a very special situation: EB did display/hide the window outside of reach with screen coordinates of (32K,32K). Luckily these coordinates were saved in the preferences and could be reset by editing preferences of the Windows
  • Dec 04
    Re[2]: [eiffel-users] linux OS call, unable to get any working function for command having a pipe. Dummy ex. : `/usr/bin/md5sum /etc/hosts | cut -f1 -d' '`
    This does not seem to be Eiffel-specific, however, would you describe the behavior you encounter and the behavior you want to have with some more details (exact command line, etc.)? Regards, Alexander Kogtenkov Gachoud Philippe : Unfortunately with a bzip command, it
  • 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

  • Dec 03
    Re: [eiffel-users] linux OS call, unable to get any working function for command having a pipe. Dummy ex. : `/usr/bin/md5sum /etc/hosts | cut -f1 -d' '`
    Unfortunately with a bzip command, it seems that it goes on with a child process which doesn't `wait_for_exit`. Anybody has a solution ? 1) reaching the child process for wait_for_exit? 2) working around with a crappy wait? what procedure in eiffel does that? Thx On Tuesday, December 3, 2019 at
  • Dec 03
    Re: [eiffel-users] linux OS call, unable to get any working function for command having a pipe. Dummy ex. : `/usr/bin/md5sum /etc/hosts | cut -f1 -d' '`
    Many Thx Alexander! Adapting the code I had, I had to add as first argument to bash or sh the `-c` to avoid getting a `cannot execute binary file` error My final code which could be useful for future readings, working on a debian 9 linux is feature -- Commands piped_command_result (a_command:
  • Dec 02
    Re: [eiffel-users] Editor Tool Completely GONE!
    FYI — I was using the 19.09 (19.10) beta. I have loaded up the project in 19.05 and all seems to be working again. After a clean compile in 19.05 (which is solid), I then attempt to open again in 19.09 (19.10) beta and still broken. Going back to 19.05 to continue. This is very odd. Where is
  • Dec 02
    Re: [eiffel-users] Editor Tool Completely GONE!
    Attempting to exit ES gives ... [image: image.png]
  • Dec 02
    Re: [eiffel-users] Editor Tool Completely GONE!
    I then get a brief flash of another Error message box, which does not have time to paint before ES finishes its destroy.
  • Dec 02
    Editor Tool Completely GONE!
    I exited a CLI Run of an Eiffel Project and hit an error. Did not save it--but--now the ES Editor(s) are completely GONE! The toolbars are also gone. The only thing I can access are some of the tools (Groups, Class, Outputs, etc). I cannot get toolbars back. I cannot get the editors. Tools
  • Dec 02
    Re: [eiffel-users] linux OS call, unable to get any working function for command having a pipe. Dummy ex. : `/usr/bin/md5sum /etc/hosts | cut -f1 -d' '`
    Thx Jocelyn, its a useful workaround, but not something which is what I want... in that case, I'll decompress the file, etc.... but its really annoying... and is there a reason for these types of commands not to work!!??? As even you are using workarounds, it seems many are working around
  • Dec 02
    Re: [eiffel-users] linux OS call, unable to get any working function for command having a pipe. Dummy ex. : `/usr/bin/md5sum /etc/hosts | cut -f1 -d' '`
    You can use something like that: command: READABLE_STRING_32 arguments: ARRAYED_LIST [READABLE_STRING_32] directory: READABLE_STRING_32 command := (create {EXECUTION_ENVIRONMENT}).default_shell if command.is_empty then
  • Dec 02
    Re[2]: [eiffel-users] linux OS call, unable to get any working function for command having a pipe. Dummy ex. : `/usr/bin/md5sum /etc/hosts | cut -f1 -d' '`
    Everything works without workarounds if the invoked command is the shell processor (sh, bash, etc.) and the argument is the command line you would like to execute. In this case there is no need to break the line into separate arguments, this will be done by the shell itself. I.e., you need to
  • Dec 02
    Re: [eiffel-users] linux OS call, unable to get any working function for command having a pipe. Dummy ex. : `/usr/bin/md5sum /etc/hosts | cut -f1 -d' '`
    This may not be the answer you expect, but quite often I tend to use a simple solution using an extra script. So I don't have to write the complex redirection, pipe, ... I just call a simple script. This is also nice for portability, as sometimes the executable is not always at the same
  • Dec 02
    linux OS call, unable to get any working function for command having a pipe. Dummy ex. : `/usr/bin/md5sum /etc/hosts | cut -f1 -d' '`
    Hi all, Since months now I'm working around shell commands which are really handy and more efficient to have some things done at the OS level than with eiffel. In this particular case I'd like to get the md5sum of the uncompressed version of a bz2 file. And having a ton of them, I dont want to
  • Dec 02
    help with my FAS class.
    so, as i was just starting my Eiffel journey i wanted to decode a file system i designed for an "engine" i'm trying to make using Eiffel. so i took the first step and tried to do this .e file within EiffelStudio after i've created my first project there. https://pastebin.com/1S5bfcRz the thing
  • Dec 02
    Re: [eiffel-users] Do I have to create a dummy file to satisfy the compiler? ;)
    Thanks for the clarification, Bertrand. Even though it's in the basics, I hadn't paid attention to attached and detachable. If I'd spotted that earlier it would have saved me a lot of trouble! ------------------------------------------------------------------------------------------- On Sunday,
  • Dec 02
    Re: [eiffel-users] Re: gobo under 19.05 - VTCT; can't find skeleton classes
    Indeed, reading https://dev.eiffel.com/EiffelStudio_19.05_Releases referenced by https://www.eiffel.org/doc/eiffelstudio/Release_notes_for_EiffelStudio_19.05 You can learn about this change in Gobo libraries. - Updated contrib/library/gobo to Gobo v4.3 . *WARNING:* you may need to add to
  • 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?

  • Dec 01
    Re: set_day into DATE_TIME
    my workaround: set_to_begining_of_month do set_date (create {DATE}.make (year, month, 1)) set_time (create {TIME}.make (0, 0, 1)) end set_to_end_of_month do set_date (create {DATE}.make (year, month, days_in_month)) set_time (create {TIME}.make (23, 59, 59)) end On Sunday, December 1,
  • Dec 01
    set_day into DATE_TIME
    Hi all! trying to implement a function I'm missing into the DATE_TIME class which would be set_day (present into DATE class), I'm running into an issue (ensure violation) of set_day (1) I'm trying to set a day_time to the first and last day of month which seems pretty useful for me, and am
  • Dec 01
    Re: set_day into DATE_TIME
    Actually, at the end of the procedure, the day is on 29 as the d parameter is 1 [image: Screenshot_20191128_060145.png] On Sunday, December 1, 2019 at 10:08:24 PM UTC, Gachoud Philippe wrote: > > Hi all! > > trying to implement a function I'm missing into the DATE_TIME class which > would be
  • Dec 01
    RE: [eiffel-users] Do I have to create a dummy file to satisfy the compiler? ;)
    ml_output_file is an attribute. Since it is declared as attached, every creation procedure has to make sure it is non-void on exit of the procedure (i.e. on start of the object’s life). The loop could be executed zero times. In that case, without the commented-out line, the attribute would be
  • Dec 01
    Re: gobo under 19.05 - VTCT; can't find skeleton classes
    I discovered that this problem can be overcome by adding .ecf entries for the libraries gobo_lexical_skl and gobo_parse_skl wherever gobo_lexical and gobo_parse have been used. - thomas
  • Nov 30
    Re: 19.05 / Windows 10 - UI resolution issues
    Just a note: I have seen signs that current bitmaps are getting transitioned to SVG and will be nicley scalable at that time.
  • Nov 30
    Re: [eiffel-users] Do I have to create a dummy file to satisfy the compiler? ;)
    Hi Alexander, I thought it self-explanatory, but when I came to put an example together for you, I realised it wasn't! Here's the 'bad' code: ml_filename: STRING ml_output_file: PLAIN_TEXT_FILE make local division_list: ARRAY[STRING] do
  • Nov 30
    Re: [eiffel-users] Do I have to create a dummy file to satisfy the compiler? ;)
    Would you share the code with the issue, please? Alexander Kogtenkov Суббота, 30 ноября 2019, 21:22 +03:00 от Curly : I am iterating across a list of items, whose names are used to create files. The compiler insists that I initialise the PLAIN_TEXT_FILE object
  • Nov 30
    Do I have to create a dummy file to satisfy the compiler? ;)
    I am iterating across a list of items, whose names are used to create files. The compiler insists that I initialise the PLAIN_TEXT_FILE object before I enter the loop. Does this mean that I have to create a dummy file pre-loop just to satisfy the compiler, or is there another way?
  • Nov 30
    gobo under 19.05 - VTCT; can't find skeleton classes
    Trying to get further recompiling ADL Workbench on 19.05... Having fixed the broken '-safe' .ecf refs from my .ecf files, I now get: 1 VTCT Type is based on unknown class YY_PARSER_SKELETON. BMM_TYPE_NAME_PARSER (eomf_bmm) 20, 2 1 VTCT Type is based on unknown class
  • 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?

  • 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
    
  • 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.

  • 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?

  • 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?

  • 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

  • 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
  • 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
    
  • 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
    
  • 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

  • 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

  • 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.

  • 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     
    
  • 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?

  • 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
    
  • 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

  • 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?

  • 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?

  • 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

  • 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

  • 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
    
  • 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

  • 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
    
  • Jun 29
    Eiffel: a way to check type conformance with a given CLASS_NAME

    I'm trying to do something as

    work (a_father: FATHER)
        do
            if a_father.conforms_to ({DEVELOPER}) then
               a_father.code
            else
               a_father.change_job ({DEVELOPER})
            end
        end
    

    enter image description here enter image description here

    the compilation works, but in my implementation @runtime it doesn't pass. What did I mistype?

  • Jun 29
    Eiffel, multiple types conformance: a way to specify that a parameter is a descendent from A and B?

    Is there a way (I'm sure there is out of runtime check...) to specify that a parameter or a variable in general conforms to multiple types? to avoid doing something such as

    work (a_printer: PRINTER; a_scanner: SCANNER)
        do
          a_printer.print
          a_scanner.scan
            -- OR without second parameter
          if attached {SCANNER} a_printer as l_scanner then
             l_scanner.scan
          else
             throw RuntimeError
          end
        end
    
  • Jun 11
    € Symbol from commandline (Arguments)
  • See more ...