Forum

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

  • Oct 03
    Gobo Eiffel 19.10 released
    This new release of Gobo Eiffel should work fine with EiffelStudio 19.05 and 19.08. Please see the release notes here: https://github.com/gobo-eiffel/gobo/blob/master/History.md You can download the Gobo package from SourceForge: https://sourceforge.net/projects/gobo-eiffel/files/gobo
  • Oct 03
    EiffelStudio 19.09, the intermediate beta release, is now available
    Dear Eiffel users, As part of our monthly beta version program, we are pleased to make EiffelStudio 19.09 available. This is an intermediate beta release towards the next official 6-month release, which will be EiffelStudio 19.11 in November. Only stable 6-month releases are officially
  • Oct 03
    Re: Transitional to Complete Void Safety
    The answer is to use the word "all" instead of "complete".
  • Oct 01
    Re: [eiffel-users] Re: Transitional to Complete Void Safety
    Hi Chris, Thanks for the feedback! I have only ever started projects off at Void Safe being Complete or Transitional, with Provisional Syntax, and Full Class Checking = True. So, starting with an ECF and working it up to that place is turning out to be challenging! :-) Cheers, Larry
  • Oct 01
    Re: Transitional to Complete Void Safety
    it may well also be that I was unable to change the Void Safety setting because I was not load/opening the root library target of the ECF! I was in a subordinate target I named "test", where the void safe settings are in the root (top-most) target. This all seems to have started when I actually
  • Oct 01
    Re: [eiffel-users] Re: Transitional to Complete Void Safety
    I ran into these types of strangeness when I was doing the same thing for a project a few years ago. I didn't document it, but just wanted to chime in to say you're not alone. On Wed, Oct 2, 2019 at 4:23 AM Larry Rix wrote: > It may well be this is the source of
  • Oct 01
    Re: Transitional to Complete Void Safety
    It may well be this is the source of the issue! This is from GitHub's view. The top line for Void-safety is what WAS and the
  • Oct 01
    Re: Transitional to Complete Void Safety
    An even BIGGER FYI!!!! I decided to see if I could use the Project Settings tool to walk the Void-safe setting back down by changing it at load time and doing a clean compile. I found that if I switched targets I was able to use the Project Settings tool to change the VS settings, and then
  • Oct 01
    Re: [eiffel-users] Configuration/version management
    Bertrand, I am not aware if the GitHub Desktop product has an external API that is consistent, but if it does, then I would suggestion some sort of configuration option that would allow ES to "wake up" a tool that knows how to interact with this API and then present some basics in the Eiffel
  • Oct 01
    Transitional to Complete Void Safety
    Hi All, I have an ECF with the following I need to take it to Complete VS, but the Project tool will not allow me to make the change. What do I need to do? Thanks!
  • Oct 01
    Re: Transitional to Complete Void Safety
    FYI—I have tried directly editing the ECF text file and changing transitional to complete in either or both "support" and "use". No matter how I set these two, Eiffel Studio then comes up with an "error" condition when reading (parsing) the ECF while attempting to open it.
  • Oct 01
    Re: [eiffel-users] Creation of NUMERIC in Void Safe System
    Hi R! Thanks for the feedback. I did consider doing this and from a human brain point of view, it works. From a compiler point of view, the compiler will simply complain that the long-complex-if-then-else (or inspect) is missing the "else", which is the "reasonable default" and give the same
  • Oct 01
    Re: Re[2]: [eiffel-users] Creation of NUMERIC in Void Safe System
    YAY! That'll do it! It turns out in this case that it was okay to change N to detachable N in the routines return type declaration. BUT—I see how your solution works. Very elegant!
  • Oct 01
    Re: [eiffel-users] Result is not being created?
    The feature `found_item` is of a detachable type. I would suggest changing the code to Result := template_table [format] if not attached Result then create Result.make (format, function_table) template_table.extend (Result, format) end Regards, Alexander Kogtenkov
  • Oct 01
    Re: [eiffel-users] Creation of NUMERIC in Void Safe System
    Hi Alex! Forgive me—my example is poor! Yes—if the example was proper, v.zero would certainly do the trick. I agree. However, the real example ought to be: 1 my_feature (c:BOOLEAN;a:ARRAY[N]): N 2 do 3 across v as ic loop 4 if c and then attached Result then 5
  • Oct 01
    Re: [eiffel-users] Creation of NUMERIC in Void Safe System
    Sorry—typo on my part. On Tuesday, October 1, 2019 at 8:06:30 AM UTC-4, Larry Rix wrote: > > Hi Alex! > > Forgive me—my example is poor! Yes—if the example was proper, v.zero would > certainly do the trick. I agree. However, the real example ought to be: > > 1 my_feature (c:BOOLEAN; v:ARRAY[N]):
  • Oct 01
    Re[2]: [eiffel-users] Creation of NUMERIC in Void Safe System
    In this case, I would suggest adding a creation constraint to parameter N: class MY_CLASS [N -> NUMERIC create default_create end] and to initialize Result before use: Result := (create {N}).zero across … (I guess, with this change, the test `attached Result` would be `True` all
  • Oct 01
    Re: Result is not being created?
    Never mind, folks! I found the issue!!! The call to "found_item" cannot be guaranteed to be attached.
  • Oct 01
    Result is not being created?
    Can someone please tell me why the following code produces the following error in a Initialization Void Safety setting? Code: template (format: STRING): EL_DATE_TEXT_TEMPLATE do if template_table.has_key (format) then Result := template_table.found_item else create Result.make (format, function_t
  • Oct 01
    Re: [eiffel-users] Creation of NUMERIC in Void Safe System
    Class NUMERIC models a ring. So, there are two distinguished elements: zero and one. You can use either of them to initialize Result. Given that the code is OK for basic types, most probably, ‘zero’ will do: Result := v.zero if c ... Hope this helps, Alexander Kogtenkov Вторник, 1
  • Oct 01
    RE: [eiffel-users] Creation of NUMERIC in Void Safe System
    Hi Larry The undefined-by-end issue is due to the missing else case (but you knew that), so a default value (a non-Void one) needs to be assigned in that case. Zero is the traditional option. Absent an else, you could simply assign the value to Result before the conditional. That leaves the
  • Oct 01
    Creation of NUMERIC in Void Safe System
    I have a class with a Generic like this: MY_CLASS [N -> NUMERIC] I then have a feature: 1 my_feature (c: BOOLEAN; v:N): N 2 do 3 if c then 4 Result := Result + v 5 end 6 end The compiler gives two errors in Transitional Void Safe mode: 1. VUTA(2)
  • 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.

  • Sep 28
    Re: [eiffel-users] Re: Eifflel-Loop & desktop GUI
    Hi Finnian! I have created a new "issue" on the ELS repo in GitHub. I will take any further communication either there, Slack, or to email from here forward.No need to clutter this thread with chatter. Kindest regards, Larry
  • Sep 28
    Re: [eiffel-users] Re: Eifflel-Loop & desktop GUI
    Hi Larry what you have uncovered is interesting. I have insert my comments Below are some examples. I am not saying these are the right choices to make, but they are the ones I made given the compiler errors. [image: image.png] The compiler complained about line #30 not having a Generic
  • Sep 28
    Re: Eifflel-Loop & desktop GUI
    Hi Larry many thanks for taking the time to do an assessment of EL for 19.05. I have inserted my comments below. Finnian—You are quite welcome! 1. It appeared that all of the EL_REFLECTED_* classes needed to be creation constrained to "create default_create end", but several of the
  • Sep 27
    Re: Eifflel-Loop & desktop GUI
    FYI—I thought I'd spend a little more time with this and discovered that a lot of the "creation constraint" issues on the REFLECTION classes was might fault—that is—I applied creation constraints where they did not need to be. I am presently down to just two error where the Generic is not
  • Sep 27
    Re: [eiffel-users] Re: Eifflel-Loop & desktop GUI
    Below are some examples. I am not saying these are the right choices to make, but they are the ones I made given the compiler errors. [image: image.png] [image: image.png] The compiler complained about line #30 not having a Generic Parameter. I think this is now being picked up because of Void
  • Sep 27
    Re: [eiffel-users] Re: Eifflel-Loop & desktop GUI
    RE: EIFGENs—Excellent! Yep—all I did was to add an appropriate gitignore and everything became manageable once more. :-)
  • Sep 27
    Re: [eiffel-users] Re: Eifflel-Loop & desktop GUI
    RE: "forever locked" — yes, I agree! It's not really forever, but not knowing when in the future deters folks from reusing and that is the thing I'd like to see EL get beyond in the present state-of-affairs of Eiffel et al.
  • Sep 27
    Re: Eifflel-Loop & desktop GUI
    Finnian—You are quite welcome! BTW—I thought I'd take an hour or two and see if I could bring the EL_base project into 19.05. At first, I thought I was being successful because I was getting errors having to do with Void Safety. BUT—now I think I am beyond those and I am starting to run into
  • 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")
    
  • Mar 10
    Eiffel shortest statement for object creation and result of function

    If I'd like to add a DATE_TIME to a logger for example I'd like to avoid creating a local variable for that. Is there any similar statement as

    create {DATE_TIME}.make_now.formatted_out ("yyyy-mm-dd hh:mi:ss")
    

    which is not possible?

  • Feb 18
    Eiffel: a way to display assertion violation on runtime of executable

    As I have the choice on finalizing a project to keep assertions, I'd think that assertion violation would be shown or displayed on console (hopefully on stderr on linux). What would be the proper way to do such, like seems that I have to add it or enable something to get it...

  • Feb 11
    Eiffel: how do I set the command line arguments of an autotest?

    Some of my tests needs something like

    {EXECUTION_ENVIRONMENT}.arguments.separate_character_option_value ('l')
    

    to be attached (not Void), how do I set commandline arguments to eiffel autotest?

  • Feb 11
    Eiffel: a proper way to inherit from a class and convert Current object to it

    It's not the first time I'm trying to inherit from a class and convert an object to it, in this case extend functionalities of HTTP_CLIENT_RESPONSE with valid_http_response => response.status = 200, valid_http_json_body => validate json content, etc...

    For that, I'd like to inherit from HTTP_CLIENT_RESPONSE and add features and create my custom DB_ENTITY_HTTP_CLIENT_RESPONSE from an HTTP_CLIENT_RESPONSE

    test_case
        local
            l_http_client_r: HTTP_CLIENT_RESPONSE
            l_db_entity_http_client_r: DB_ENTITY_HTTP_CLIENT_RESPONSE
        do
            l_http_client_r := execute_get("someURL") -- returns an HTTP_CLIENT_RESPONSE
            l_db_entity_http_client_r := l_http_client_r
            assert("valid response", l_db_entity_http_client_r.valid_response)
        end
    

    it seems I've difficulties having the internal properties set... what would be the best way to do this? I had the same case trying to create a WATT class inheriting from NATURAL_32 which is an expanded.

    In my strategy, I tried to call in creator

    • a parent creation procedure
    • then call a deep_copy

    Here is the rest of my class attempt:

    class
        DB_ENTITY_HTTP_CLIENT_RESPONSE
    
    inherit
        HTTP_CLIENT_RESPONSE
    
    create
        make_from_http_client_response
    
    convert
        make_from_http_client_response ({HTTP_CLIENT_RESPONSE})
    
    feature -- Initialization
    
        make_from_http_client_response (a_client_response: HTTP_CLIENT_RESPONSE)
            do
                make (a_client_response.url)
                deep_copy (a_client_response)
            end
    
    feature -- Status report
    
        valid_response: BOOLEAN
            do
                Result := status = 200
            end
    

    The only way I found working for now is by setting all attributes to other which is the semantic of deep_copy normally...

    make_from_http_client_response (a_client_response: HTTP_CLIENT_RESPONSE)
        do
            make (a_client_response.url)
            set_body (a_client_response.body)
            set_http_version (a_client_response.http_version)
            set_error_occurred (a_client_response.error_occurred)
            set_error_message (a_client_response.error_message)
            set_raw_header (a_client_response.raw_header)
            set_status_line (a_client_response.status_line)
            ... I surely forgot something...
        end
    
  • Feb 10
    Eiffel: is there a way with do_all or do_if to search for an element in a collection without having to write a whole feature?
    across
        collection as l_item
    until 
        Result /= Void
    loop
        if l_item.item.name.is_equal ("foo") then
            Result := l_item.item
        end
    end
    

    is there a way and if so which one to do something like

    collection.do_if (agent ...)
    

    an example of use can be:

    search_item_with_id (an_id: INTEGER)
            -- Moves items cursor if not found is_after
        local
            l_found: BOOLEAN
        do
            from
                items.start
            until
                items.after or l_found
            loop
                l_found := items.item.primary_key = an_id
                if not l_found then
                    items.forth
                end
            end
        ensure
            cursor_on_element_if_found: not items.after implies items.item.primary_key = an_id
        end
    
  • Feb 01
    Eiffel: ODBC Dealing with BIGINT

    Eiffel

    Seems I'm getting an INTEGER_32_REF from a BIGINT from ODBC with Eiffel DB_SELECTION.cursor. Sometimes I seem to have the adecuate value, but sometimes not...

    946383958 => good INTEGER_32_REF (id->4 of following table)
    9475984837 => 886050245 WRONG INTEGER_32_REF (id->4 of following table)
    
    646383958 => good INTEGER_32_REF (id->3 of following table)
    6475984837 => -2113949755 WRONG INTEGER_32_REF (id->4 of following table)
    
    ...
    

    It seems to behave like not treating the BIGINT and giving the INTEGER_32_REF value directly interpreted from the DB value, typical case passing over the 2^32

    Postgresql

    Having a table with following data as electricity_amount BIGINT NOT NULL DEFAULT 0

    id |   a_date   |  amount   | electricity_amount | consumption_sector_id | electricity_rate_id
    ----+------------+-----------+--------------------+-----------------------+---------------------
    1 | 2019-01-01 | 746383958 |         7475984837 |                     1 |                   1
    2 | 2019-02-01 | 846383958 |         8475984837 |                     1 |                   1
    3 | 2019-03-01 | 646383958 |         6475984837 |                     1 |                   1
    4 | 2019-04-01 | 946383958 |         9475984837 |                     1 |                   1
    

    enter image description here

  • Jan 31
    Eiffel: non-compatible actual argument in feature call

    I don't understand why it is so.

    • If I say attached {G} it works
    • If I say nothing which would be the expected behavior for me calling_entity: detachable RELATED_DB_ENTITY should be conform (once attached) to G which is -> DB_ENTITY
    • If I say DB_ENTITY it doesn't
    • If I say RELATED_DB_ENTITY either does it pass

    Why do I have to specify {G}???

    SIT_HANDLER

    class
        SIT_HANDLER[G -> DB_ENTITY create default_create, make_from_db_service, make_from_json end]
    
    feature --
    
        some_feature
            do
                if attached {G} l_rest_request.calling_entity as l_calling_entity then
                    db_service.set_item_prototype (l_calling_entity) -- Complains here!!!!!!!!!!!!
                    db_service.load_with_relationships (l_rest_request)
                ...
            end
    end -- class
    

    REST_REQUEST

    class
        REST_REQUEST
    
    feature -- Access
        calling_entity: detachable RELATED_DB_ENTITY -- RELATED_DB_ENTITY inherits DB_ENTITY
    ...
    end -- class
    

    DB_SERVICE

    class
        DB_SERVICE [G -> DB_ENTITY create default_create, make_from_db_service, make_from_json end]
    
    feature -- Status setting
    
        item_prototype: G
    
        set_item_prototype (v: like item_prototype)
            do
                item_prototype := v
            ensure
                item_prototype = v
            end
    
    ...
    end -- class
    

    enter image description here

  • Jan 30
    Eiffel: setting a constant with reference to other class constant

    How to set a constant refering to another class constant in Eiffel?

    Something like that doesn't compile unfortunately

    Default_log_level: like {MY_LOGGER}.log_level = {MY_LOGGER}.Log_level_info
    
  • See more ...