Forum

  • Nov 18
    Re: [eiffel-users] Compiler hanging at degree 3
    Only other choice is to delete the EIFGENs folder, which will force a clean compile.
  • Nov 17
    Re: [eiffel-users] Compiler hanging at degree 3
    Tried that. Checked "clean" from opening dialog. This that enough to clean it all? On Sunday, November 17, 2019 at 4:02:21 PM UTC-7, Larry Rix wrote: > > I don't think so, but I would start with a clean compile. >
  • Nov 17
    Re: [eiffel-users] Compiler hanging at degree 3
    I don't think so, but I would start with a clean compile.
  • Nov 17
    Compiler hanging at degree 3
    After making changes to a couple of files the compiler now pauses for a long time at degree 3 for 3 or 4 minutes, when before it only took a few seconds. The main change which might be relevant is I added about 100 features defined like: f: MY_CLASS attribute create Result.make end Could
  • 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
    Re: [eiffel-users] Re: index_small_enough -> ARRAYED_LIST[PATH] bug or misuse?
    If you want to avoid duplicating memory, you should not use `across` but `from until loop` instead and move the cursor according to your deletion or addition (e.g. not call `forth` if the deletion already moved the cursor to the next item). -- Eric Bezault mailto:er...@gobosoft.com
  • Nov 15
    Re: index_small_enough -> ARRAYED_LIST[PATH] bug or misuse?
    Is it because I prune while I'm iterating? On Friday, November 15, 2019 at 4:02:42 PM UTC, Gachoud Philippe wrote: > > Hi, > > a case which seems very simple to me but where I'm missing something... > > I have some > > files_entries: ARRAYED_LIST[PATH] > > > which I fill with a DIRECTORY_ITERATOR >
  • Nov 15
    Re: [eiffel-users] Re: index_small_enough -> ARRAYED_LIST[PATH] bug or misuse?
    And there's the other solution. :-)
  • Nov 15
    index_small_enough -> ARRAYED_LIST[PATH] bug or misuse?
    Hi, a case which seems very simple to me but where I'm missing something... I have some files_entries: ARRAYED_LIST[PATH] which I fill with a DIRECTORY_ITERATOR When I try to remove some based on a regex I get a index_small_enough: CHECK_VIOLATION raised > error. With what am I wrong,
  • Nov 15
    Re: [eiffel-users] Re: index_small_enough -> ARRAYED_LIST[PATH] bug or misuse?
    I think you have identified the issue you are referring to. Do not prune (or grow) what you iterate—ever! Horrid source of bugs. Instead, create a twin and prune or grow the twin and then either send the collection to whatever needs it—or—replace your source list.
  • Nov 15
    Re: [eiffel-users] Re: index_small_enough -> ARRAYED_LIST[PATH] bug or misuse?
    Many thx Larry, I wanted to avoid memory loss, as if I was paying it myself ;-) On Friday, November 15, 2019 at 4:13:06 PM UTC, Larry Rix wrote: > > I think you have identified the issue you are referring to. Do not prune > (or grow) what you iterate—ever! Horrid source of bugs. > > Instead,
  • Nov 15
    Re: [eiffel-users] Re: WrapC VS SOD
    I am back on Slack if you happen to be on and available.
  • 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
    Re: [eiffel-users] Re: WrapC VS SOD
    Yes, let's continue using slack. On Wednesday, November 13, 2019 at 3:08:08 PM UTC-3, Larry Rix wrote: > > If you look in your Slack eiffel-web personal channel you will find some > additional information from me. >
  • Nov 13
    Re: [eiffel-users] Re: WrapC VS SOD
    BTW--I made you a collaborator on the GitHub project. Feel free to clone and make any direct changes you like. I know I have hard coded paths, but change them to what you like and need and I can then make alterations/modifications on my end afterwards. On Wednesday, November 13, 2019 at 11:54:32
  • Nov 13
    Re: [eiffel-users] Re: WrapC VS SOD
    If you look in your Slack eiffel-web personal channel you will find some additional information from me.
  • Nov 13
    Re: [eiffel-users] Re: WrapC VS SOD
    I have pushed two changes to GitHub: 1. In the ECF, changed the total order of reals from false to true. 2. I saved the output of the external compilation to a file to preserve it. Item #1 handled a reported error, which suggested the change made to the ECF. Subsequent compiles no
  • Nov 13
    Re: [eiffel-users] Re: WrapC VS SOD
    BTW—I attempted to use the versions of stddef.h that shipped with Eiffel Studio, but got errors when using them. I am presuming that the typedefs in the stddef.h file I used from MIT are incorrect given the sod.h, its code, and the compiler I am using. I am also flying blind about my Advanced
  • Nov 13
    Re: [eiffel-users] Re: WrapC VS SOD
  • Nov 13
    Re: [eiffel-users] Re: WrapC VS SOD
    Javier, I used the stddef.h file found at: http://web.mit.edu/cygwin/cygwin_vold/i586-cygwin32/include/mingw32/stddef.h I co-located this in the "sod" folder (the repo folder cloned from GitHub). I referenced the file in the sod.h with the following: #include "D:\Users\LJR19\Documents\GitHub\so
  • Nov 13
    Re: [eiffel-users] Re: WrapC VS SOD
    The failure is because the wrap_c.exe cannot locate the stddef.h file. The only way I could get it to work was to use a stddef.h file I found and placed directly in the sod folder. [image: image.png]
  • Nov 13
    Re: [eiffel-users] Re: WrapC VS SOD
    Hi Larry, do you have a github repository with the code? Can you show me how do you include the header stddef.h? Just add #include . and no need to copy a specific header in the sod folder. /Javier On Wednesday, November 13, 2019 at 11:49:16 AM UTC-3, Larry Rix wrote: > > Hey Javier, >
  • Nov 13
    Re: [eiffel-users] Re: WrapC VS SOD
    Are you on Slack? If so, perhaps we can take this interaction there and just report the solution here.
  • Nov 13
    Re: [eiffel-users] Re: WrapC VS SOD
    Hey Javier, It has been way too long ago that I touched C/C++. Can you see what's wrong with it? [image: image.png]
  • 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
  • Nov 12
    Re: WrapC VS SOD
    Excellent!
  • Nov 12
    Re: WrapC VS SOD
    The library Lib SOD is written in C99, On windows when we use VisualStudio in C mode, it follows the C standard from 1990, and WrapC uses the visual studio preprocessor and unfortunatelly it does not support C99. In this particular case the issue is in callback definition the parameter size_t
  • Nov 12
    Re: [eiffel-users] Re: WrapC VS SOD
    Is there a particular version of I ought to use? [image: image.png]
  • 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 23
    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

  • 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)
  • Apr 20
    Problems compiling Traffic library

    I attempted to install the Traffic library for the book "A Touch of Class" but was not able to compile the examples. EiffelStudio complained about a base2.ecf file. Error code: VD00

    General configuration parsing error. What to do: fix the configuration file.

    Could not open file: \base2.ecf $EIFFELBASE2\base2.ecf

    base2.ecf is found in where Windows installed Eiffel: C:\Program Files\Eiffel Software\EiffelStudio 18.11 GPL\unstable\library\base2.ecf The offending line of code seems to be this in the Traffic configuration files:

    I have attempted to change this configuration file pointing directly to where the file is, using the actual path, to no avail.

  • Apr 05
    Eiffel: passing argument to agent received as argument

    I'm really stuck in how to pass an argument to a second level of an Eiffel agent call. Hope my example is enough self explaining:

    main_call
        do
            b (agent d(?, ?))
        end
    
    b (a_proc: PROCEDURE[STRING])
        local
            l_something_else: INTEGER
        do
            l_something_else := 1
    --        z("a_line", a_proc(l_something_else)) -- How can I pass at this stade l_something_else to the d procedure!!!
        end
    
    d (line: STRING; something_else: INTEGER)
        do
    --        do_some_stuff_with_line (line, something_else)
            do_nothing
        end
    
    z (a_line: STRING; a_proc: PROCEDURE[STRING])
        do
            a_proc.call([a_line])
        end
    

    I would have liked to be able to do something like

    z("a_line", a_proc(?, something_else))
    

    But its not possible, as I try with the agent keyword, the a_proc argument is not recognized!

    So what would be the syntax? I even tried to add an argument to a_proc with a_proc.set_operands but am lost with the OPEN_ARGS class

    Implementation case

    If you need a goal... just imagine I'd like to have 2 different implementations of the d function, and in my case its using UT_CSV_HANDLER that I'd like to have 2 different functions for each line of a CVS

    The following code gives a Non-compatible actual argument in feature call

    Feature: import_from_csv_impl
    Called feature: import_from_csv_impl (a_rest_request: REST_REQUEST; a_procedure: PROCEDURE [DS_ARRAYED_LIST [STRING_8], INTEGER_64, STRING_8]): [detachable like items] detachable SIT_LINKED_LIST [MEASURING_POINT] from MEASURING_POI...
    Argument name: ia_name
    Argument position: 2
    Formal argument type: STRING_8
    Actual argument type: INTEGER_64
    Line: 258
                    ia_procedure.call (ia_measuring_point_id, ia_name)
    ->            end (?, l_measuring_point_id, l_s)
                l_csv_handler.read_file (l_is, l_partially_closed)
    

    The complete example:

    -- Main call
    import_from_abb_csv (a_rest_request: REST_REQUEST): detachable like items 
        do
            Result := import_from_csv_impl (a_rest_request, agent impl_for_each_csv_line_import_from_abb_csv)
        end
    
    -- Second call
    import_from_csv_impl (a_rest_request: REST_REQUEST; a_procedure: PROCEDURE[DS_ARRAYED_LIST [STRING_8], INTEGER_64, STRING]): detachable like items
        local
            l_csv_handler: UT_CSV_HANDLER
            l_is: KL_STRING_INPUT_STREAM
            l_measuring_point_id: INTEGER_64
            l_s: STRING
            l_partially_closed: PROCEDURE[DS_ARRAYED_LIST[STRING]]
        do
            l_s := "whatever"
            l_measuring_point_id := 12
            create l_csv_handler.make_with_separator (',')
    
            l_partially_closed := agent (i_al: DS_ARRAYED_LIST[STRING]; ia_measuring_point_id: INTEGER_64; ia_name: STRING; ia_procedure: PROCEDURE[INTEGER_64, STRING])
                do
                    ia_procedure.call (ia_measuring_point_id, ia_name)
                end (?, l_measuring_point_id, l_s)
    
            l_csv_handler.read_file (l_is, l_partially_closed)
    
        end
    
    -- end call
    impl_for_each_csv_line_import_from_abb_csv (a_csv_line: DS_ARRAYED_LIST [STRING_8]; a_measuring_point_id: INTEGER_64; l_cu_name: STRING)
        do
            -- do_my_business
        end
    
    
    -- for information signature of read_file is:
    --     read_file (a_file: KI_TEXT_INPUT_STREAM; a_action: PROCEDURE [DS_ARRAYED_LIST [STRING]])
    
  • Apr 05
    Eiffel: type conformance, how to give a type instead of an instance

    General

    I don't understand why there are like 2 generating_type kinds, the one with exclamation point, and the other not.

    My case

    I have a function returning a DB_SERVICE[G] from a given instance from a collection of db_services so that from another service I can retrieve it and call it. When I pass an instance generating_type to that function, the conforms_to returns True, as when I give ({ENUMERATE}).generating_type it doesn't.

    Why is that so?

    -- Humanly unreadable
    if attached {ENUMERATE_DB_SERVICE} {SIT_ENVIRONMENT}.app_instance.db_service_from_entity_type (item_prototype.charge_unit_relationship.secondary_prototype.an_index_relationship.secondary_prototype.generating_type) as l_enum_dbs then
    
    -- Humanly readable but not working
    if attached {ENUMERATE_DB_SERVICE} {SIT_ENVIRONMENT}.app_instance.db_service_from_entity_type (({ENUMERATE}).generating_type) as l_enum_dbs then
    

    My function

    db_service_from_entity_type (an_entity_type: TYPE[detachable DB_ENTITY]): detachable like db_services.item
        do
            across
                db_services as l_dbs
            until
                Result /= Void
            loop
                if l_dbs.item.item_prototype.generating_type.conforms_to (an_entity_type) then
                    Result := l_dbs.item
                end
            end
        ensure
            service_found: attached Result
        end
    

    Edit (20190405-11:26 UTC)

    As the screenshot shows, giving {ENUMERATE} instead of ({ENUMERATE}).generating_type doesn't work either

    enter image description here

  • Mar 29
    Eiffel: Creating a datetime with '' format

    Seems I'm wrong creating a datetime from string using this method, any idea why? The precondition violates on date_time_valid: date_time_valid (s, code)

    create l_date_time.make_from_string ("2019-03-28T15:28:02Z", "yyyy-mm-ddThh:mi:ssZ")
    
  • See more ...