Forum

  • Dec 14
    How to check if file exists in Eiffel
    feature 
    
        open_file_sample
            local
                l_file: UNIX_FILE_INFO
                l_path: STRING
            do
                make
                l_path := "/var/log/syslog"
                l_file.update (l_path)
                if l_file.parent_directory.exists and then l_file.parent_directory.is_writtable then
                    create l_file.make
                end
                 -- AS the above statement doesn't exist!
                check
                    syslog_file_exists_and_is_readable: l_file.exists and then l_file.is_readable
                end
            end
    

    Is this the proper way to check for file existence in Eiffel?

    I was wondering if there is a way not to create 2 objects. I'll complete my check with following statement:

    • define path `l_file_path := "/some/path/with_file.log"
    • check if parent directory exists and has rights to write into
    • create log file
  • Dec 14
    Eiffel: How do I handle timezones?

    I didn't find any notion of timezone DATE_TIME class and TIME class. Am I wrong?

    How do I handle timezones with Eiffel library?

    Is there a way to specify it from the {DATE_TIME}.formated_out ("YYYY-MM-DD [0]hh:[0]mi:[0]ss")

    Is there a setter for timezone?

    I already got this problem with the logger which is logging with UTC...

    The only workaround I found was l.hour_add (-3) before the formated_out which is really dirty

  • Dec 13
    Eiffel compilation through Makefile and `dpkg-buildpackage -us -uc` generating an error
  • Dec 12
    Error in profiling documentation
    This page: https://www.eiffel.org/doc/eiffelstudio/Profiling does not mention it is necessary to also turn on the profiling option at the library level. This seems to be especially important if you creation procedure is in a library (just guessing there, but in such a case, profiling writes an
  • Dec 10
    How to use CURSOR_TREE class in Eiffel?

    Does this work for removing first two children from a node?

    remove_children(current_node : CURSOR_TREE[EXPRESSION]) 
            do
                current_node.down (1)
                current_node.remove
                current_node.forth
                current_node.remove
            end
    

    Or does that only remove the current_node?

  • Dec 10
    Re: [eiffel-users] Re: Eiffel Selenium Binding
    Hi, thanks for the comparison document. On Friday, December 7, 2018 at 4:16:43 PM UTC-3, toff.tillman wrote: > > I attached a quick comparison of the JSONWireProtocol and WebDriver API > commands from those referenced pages. It seems the WebDriver is mostly a > subset of JSONWireProtocol, with a
  • Dec 09
    Is it possible to enforce Design by Contract checks at compile time?

    Reading Design by Contract tutorial I stumbled upon the following line:

    Contracts in Eiffel are not just wishful thinking. They can be monitored at run time under the control of compilation options.

    followed by explanations that they will throw exceptions when fail. It makes me think that all the require ensure invariant all checks can be either performed at runtime or turned off. Is this correct? Or they can be enforced at compile time as well using appropriate compiler options?

  • Dec 09
    Re: [eiffel-users] Re: EV_WORLD widgets with Pick-and-drop
    So, for anyone interested: The stacking/complexity of the EV_MODELs had nothing to do with the way the pick-and-drop was working. The `pebble_function' for a model was not getting called because I had used `set_pebble' on that model. The `pebble_function' gets called now that I removed the
  • Dec 09
    eiffel c compilation failure: error LNK2001: unresolved external symbol
  • Dec 09
    Persistent Eiffel
    For anyone interested -- a prototype Eiffel compiler that automates persistence of objects can be found at: https://github.com/boxer41a/P-Eiffel jjj
  • Dec 09
    Re: EV_MODEL_TEXT.is_rotatable ?
    Finnian, Thanks for the reply. Looks interesting, but all the caveats make the EL extensions a bit heavy handed for my application. Is it possible to draw the EV_MODEL_TEXT (with the correct background color, if not transparent or no background), capture that as an EV_MODEL_PIXMAP, then rotate
  • Dec 07
    Re: [eiffel-users] Re: Eiffel Selenium Binding
    I attached a quick comparison of the JSONWireProtocol and WebDriver API commands from those referenced pages. It seems the WebDriver is mostly a subset of JSONWireProtocol, with a few extensions and new commands. There are also a couple of semantic differences, e.g. size/position vs. rect. The
  • Dec 07
    Re: [eiffel-users] Re: Eiffel Selenium Binding
    Hi Larry and Anders, I've updated the code, to use JSON Serialization API updated HTTP_CLIENT to use DEFAULT_HTTP_CLIENT, so now we can use cURL and EiffelNet. I've been checking the Selenium site and it seems the JSONWireProtocol is now deprecated https://github.com/SeleniumHQ/selenium/wiki/Jso
  • Dec 05
    Re: [eiffel-users] Re: WEL Control Style Changes in Finalized Project
    Ah yes of course, thank you, works like a charm now :) On Wed, Dec 5, 2018 at 12:33 PM Larry Rix wrote: > Place the manifest file in the same directory as the EXE. Windows knows to > find it. > > -- > You received this message because you are subscribed to the
  • Dec 05
    Re: [eiffel-users] Re: WEL Control Style Changes in Finalized Project
    Place the manifest file in the same directory as the EXE. Windows knows to find it.
  • Dec 05
    Re: [eiffel-users] Re: WEL Control Style Changes in Finalized Project
    Hi Larry, Thanks for this and I'm a little stuck on where to put this manifest file as it looks like one is generated by Eiffel already for the W_CODE and F_CODE folders. If I try and replace the one in the F_CODE folder it is replaced by EiffelStudio when I finalize the project. Any further
  • Dec 04
    Re: WEL Control Style Changes in Finalized Project
    You need a "manifest" file. See here. We had the same issue with an application we were building a few years back. Here is the manifest file we used:
  • Dec 04
    WEL Control Style Changes in Finalized Project
    This is a bit of an odd one where I have two different styles appear in my project when it comes to WEL controls, i.e. buttons, list boxes etc., where in debug mode (frozen project) the controls appear in what I would describe a Windows 10 style, but once I finalize a project they come out
  • Dec 03
    Re: [eiffel-users] How to compile final binary without debug statements
    On the command-line we have the option -config_option. But despite its name, it does not allow to override ECF options, only ECF settings and capabilities. Currently options can be set at the target level, and overridden at the cluster level or class level. They cannot be set (or overridden at
  • Dec 03
    Re: [eiffel-users] How to compile final binary without debug statements
    So far, I don't see any simple solution. Usually, people use the "debug" during development, and when releasing a library or product, the debug are not enabled anymore. So this is not a frequent need. However, I could also see the benefit of having a way to enable (or disable debug) clauses at
  • Dec 03
    Eiffel: are the convert methods working in case of agent call arguments?

    I'm calling a procedure with an argument which is an integer_64. I implemented a WATT class which can create it from an INTEGER_64 and it seems the execution stops when reached this point, where am I wrong?

    Catcall detected for argument#1args': expected TUPLE [!WATT] but got TUPLE [INTEGER_64]`

    code_and_situation

    Attached case (Update)

    Actually when checking with syntax

    attached {INTEGER_64} my_watt_object as l_int
    

    enter image description here

    it doesn't pass either... is it the expected behaviour?

    Actually it seems for me that the semantic cases are the same which have to validate the conformity step... for me (but seems not to be the case for the definition of the language between conformance/conformity) which says

    Conformance and convertibility are exclusive of each other, p.87

    Is the conformance rule valid for a type which defines as convert a type to another which is my case from WATT to INTEGER_64?

  • Dec 03
    Eiffel: how do I get the type of a particular operand of a procedure

    As I can see into the debugger it's possible to get the operands, and name of procedure, is there a way to get it?

    • PROCEDURE=>operands returns a detachable that seems return the operands only when they have been setted into the agent
    • Do I have pass through any REFLECTOR class because the PROCEDURE class doesn't have this function and in this case why?

    enter image description here

    Seems that estudio has access to informations as ROUTINE client don't have, why is he a privileged one? is he cheating?

  • Dec 02
    Set Theory 0.30.d released
    Release notes 0.30.d: - Specifications, properties, implementation and tests were rewritten as much as possible to leverage from using agents. - Several new features, intended to be used instead of in-line agents, were specified, implemented and tested. - Documentation: -
  • Dec 02
    Re: [eiffel-users] Re: EV_WORLD widgets with Pick-and-drop
    No, in fact the polygon, and all other parts of this EV_MODEL, should be a single entity for events such as mouse clicks. Maybe I can convert the figure into an EV_MODEL_PIXMAP and still have other functions such as scaling work, but I bet not. Because building the figure is so complicated
  • Nov 30
    Re: [eiffel-users] HTTP/3 in Eiffel - are you interested?
    Alex, You all can count on me! I will be able to devote a block of time for sure. I have some arrangements I am making in my personal and business life that ought to afford me this time in about 2 months time.
  • Nov 30
    HTTP/3 in Eiffel - are you interested?
    Dear Eiffel developers, One of the libraries actively used in several projects across the world is EiffelWeb. Started as EWF (Eiffel Web Framework) a few years ago, it is still under active improvements coming from both the original authors and the developers who use it. Among other facilities,
  • Nov 29
    RE: [eiffel-users] Re: EV_WORLD widgets with Pick-and-drop
    Hi Jimmy Is it necessary that the polygon be treated as a separate object, or could it be fixed in place? If the latter, then you can easily create a pixmap (or pixel buffer) with the ship as bg and then draw the polygon onto it, adding it to the bg. Then the new, combined pixmap can get the
  • Nov 29
    Re: [eiffel-users] Re: EV_WORLD widgets with Pick-and-drop
    No, thanks for asking. On Wednesday, November 28, 2018 at 3:21:08 AM UTC-7, aweissen wrote: > > Hi Jimmy - > > Out of curiosity, did you get an answer to your questions? > > Anthony > > On Sat, Nov 10, 2018 at 10:16 PM jjj wrote: > >> After a simplified test, I think I know what
  • Nov 28
    Re: [eiffel-users] Gobo Eiffel 4.3 released
    Eric! YAY!!! ... awesome news!!!
  • Nov 28
    Gobo Eiffel 4.3 released
    In this release, all tools and examples, and nearly all tests, have been converted to void-safe mode. The usage of Xace files has been replaced by ECF files throughout the entire Gobo package. There was no need to keep both Xace and ECF notations in parallel anymore since all supported Eiffel
  • Nov 28
    Re: [eiffel-users] Re: EV_WORLD widgets with Pick-and-drop
    Hi Jimmy - Out of curiosity, did you get an answer to your questions? Anthony On Sat, Nov 10, 2018 at 10:16 PM jjj wrote: > After a simplified test, I think I know what to ask: > > 1) How do I prevent an EV_MODEL_POLYGON that is on top of my SHIP_WIDGET > (an EV_MODEL_WORLD,
  • Nov 27
    Re: [eiffel-users] How to compile final binary without debug statements
    https://www.eiffel.org/doc/eiffelstudio/EiffelStudio-_Using_command_line_options
  • Nov 27
    How to compile final binary without debug statements
    Hi All, What's the trick to compile a final binary without any debug statements? I thought "-finalize" would do that trick but it doesn't. Both "ec" and "eiffel" have the same behaviour, they leave any enabled debug options in .ecf on. -- All the best, Berend de Boer
  • Nov 15
    Eiffel: What's the difference between an "eiffel" library and a gobo library?

    Eiffel: What's the difference between an "eiffel" library and a gobo library? for example with xml, which should I choose and why?

    enter image description here

  • Nov 12
    How would one read space separated input in Eiffel?

    I can't really use Io.read_integer as that just ignores everything except the first number.

    I can use Io.read_line to get something like 15 14 59 86. How would I split these into integers now?

    Javascript has split(), C++ has stringstream, something similar would be ideal.

  • Oct 31
    Eiffel: type casting operators whats the difference between ~ / and attached statements?

    Whats the difference between

    • object test

      if attached {DOG} an_animal as a_dog then
         a_dog.eat (meat)
      end
      
    • operator / of the class TYPE

      if an_animal / a_dog then
         an_animal.eat (food)
      end
      
    • reference equality =

      if a_dog = an_animal then
          a_dog.eat (meat)
      else
          an_animal.eat (food) 
      end
      
    • object equality ~

      if a_dog ~ an_animal then
          a_dog.eat (meat)
      else
          an_animal.eat (food) 
      end
      

    And where can I find documentation about that?

  • Oct 30
    Eiffel: is there a way to prohibit the use of any particularly inherited creation method?

    As default_create is always a an example of creation method which can be used for instance creation as create some_instance if I don't want to allow the descendants of a class to use it as a creation method is there a way to do that?

    A

    deferred class A
    feature
       make (a_db_connection: DB_CONNECTION)
          do
              default_create
              db_connection := a_db_connection
          end
    

    B

    class B
    inherit
        A
    create
        make
        -- default_create -- I'd be able to do that and want to avoid it
    
  • Oct 29
    Eiffel: create at runtime a typed object

    Trying to create an object which is decided @runtime I have a similar situation as:

    class ZOO
    
    feature
    
        animals: LINKED_LIST[ANIMAL]
    
        default_create
            do
                create animals.make
                animals.extend(create {LION})
                animals.extend(create {SERPENT})
                animals.extend(create {BIRD})
            end
    
        open
            local
                l_sector: ZOO_SECTOR[ANIMAL]
            do
                across
                    animals as animal
                loop
                    create {ZOO_SECTOR[animal.item.generating_type]} l_sector
                end
            end
    

    on create {ZOO_SECTOR[animal.item.generating_type]} l_sector the compiler disagrees with me, I tried with l_type: TYPE[ANIMAL] and create {ZOO_SECTOR[l_type]} l_sector which neither works. Am I obligated to do something like that? which will be for me a contradiction with polymorphism flexibility, I think I'm missing a mecanism/statement

    open
        local
            l_sector: ZOO_SECTOR[ANIMAL]
        do
            across
                animals as animal
            loop
                if attached {LION} animal.item then
                    create {ZOO_SECTOR[LION]} l_sector
                else if attached {SERPENT} animal.item then
                    create {ZOO_SECTOR[SERPENT]} l_sector
                else
                    .....
            end
        end
    
  • Oct 27
    Eiffel: How do I compare the type of an object to a given type?

    How do I compare the type of an object to a given type (instanceOf statement in Java)?

    do_stuff (a_type: TYPE)
        local
            an_object: ANY
        do
            an_object := get_from_sky
            if an_object.instanceOf (a_type) then
                io.putstring("Object is same type as parameter")
            else
                io.putstring("Object is NOT same type as parameter")
            end
        end
    
  • Oct 26
    Eiffel: best practices for creation procedures

    Animal

    deferred class ANIMAL
    inherit
        ANY
            redefine
                default_create
            end
    feature
    
        creator: like Current
    
        guts: GUTS
    
        default_create
            do
                create guts
            end
    
        make_malformed
            do
                default_create
            end
    
    end --class
    

    PIG

    class PIG
    
    inherit
        ANIMAL
            redefine
                make_malformed
            end
    
    create
        default_create,
        make_malformed,
        make_from_insemination
    
    feature
        guts: GUTS
    
        make_malformed
            do
                Precursor
                set_left_eye (create {MALFORMED_EYE})
            end
    
        make_from_insemination (some_humain: HUMAIN)
            do
                default_create
                creator := some_humain
            end
    
    end --class
    

    Into my vision of best practices, I'll say that

    • If there is no particular sense of making a creation procedure (like my make_malformed example) redefine the default_create
    • All creation procedure should call default_create and add specific behavior (like my make_from_db example)
    • So what is the purpose of many libraries in Eiffel which are adding a make like create {LINKED_LIST}.make

    Correct me if I'm wrong. Thanks in advance!

  • Oct 25
    Eiffel: Recommendation for ORM (Object Relationship Model) design

    Recommendations I understood in Java (which has a lot of restrictions, @ least for me), even with hibernate was to have separated layers

    • Entities like persons, children, users, etc...
    • DAO entities linked to database
    • Service providing entities and functionalities, where I'll do the SQL
    • WebService providing an interface over needs

    As I'm starting with Eiffel and store, I'm facing some difficulties I face since ever in programming (hoping there's somebody in this earth who has not the same problem) I always want to generalize things more than necessary. Every time I do a copy-paste, I refactor and look for a solution which makes me able to write it one time... which takes time and time on the delivery of the software, but for me adds more quality and flexibility to the software. I'm actually working alone in a company where I'm going to be the lead developer and if the future wants we'll be more developers. The goal is to develop a platform of services in Eiffel, postgresql-odbc, and an Angular-web front-end.

    I'd like to have the more generic pattern to be able to manage entities in the future with typical situations as:

    • Database entities
    • Relationships
      • one_to_one
      • one_to_many
      • many_to_one
      • many_to_many

    @ The point I'm now, I'm about to develop an architecture which ideally for me has:

    • DB_ENTITY which as relations: BAG[RELATIONSHIP[P,S]] where P=Primary and S=Secondary
    • Primary is P->DB_ENTITY when ONE and BAG[P] when MANY
    • A COMPANY on my design will inherit from DB_ENTITY and add relationships as a BRANCH. So I was thinking having in my COMPANY class branches: RELATIONSHIP[like Current, BRANCH]

    The relationship classes would help me to create the CRUD SQL statements into the "service" layer in a more abstract manner.

    enter image description here

    • when I try something more lightweight I find restrictions in the pattern where I have to repeat operations... thats a bit my difficulty
    • Do you think of any disadvantages of such model I'm creating out of the first shot of development?
  • Oct 22
    Eiffel: Invalid constraint for formal generic paramete

    Following with strange patterns for some, can't I do that? The compiler says Invalid constraint for formal generic parameter

    class PARENT[G -> CHILD[like Current]]
    
    feature -- Access
    
        children: LIST[G]
    
    end
    
    class CHILD[H -> PARENT[like Current]]
    
    feature -- Access
    
        father: H
    end
    

    to be able to do something like

    class WIDOW_PARENT
    
    inherit
        PARENT[BLACK_CHILD]
    
    end
    
    class BLACK_CHILD
    
    inherit 
        CHILD[WIDOW_PARENT]
    
    end
    

    If I don't do it with genericity, I'd have to redefine the children collection from

    • children: LIST[CHILD] to children: LIST[BLACK_CHILD] into the WIDOW_PARENT class
    • father: PARENT to father: WIDOW_PARENT into the BLACK_CHILD class

    instead of only specify it in the inherit clause... Hope it makes sense

    Update

    As I solved it with Alexanders answer, I'm stuck further doing a conformity check. I'm trying to set an HTTP router depending on entities and if its a child entity it should be able to do a http://host:port/entity/child_entity/id to get all child entities from entity. For that I'd like to add to the generic router a check. On something like ANY_PARENT_DB_ENTITY such as

    if ({G}).conforms_to ({CHILD_DB_ENTITY[ANY_PARENT_DB_ENTITY]}) then
        friend.act_like_a_father 
    else
        friend.act_like_a_mate
    end
    
  • Oct 19
    Eiffel: Is there a way to test a given Generic parameter of a Class without any attached instance of it?

    Is there a way to test a given Generic parameter of a Class without any attached instance of it?

    class BAG[G -> MOUSE]
    
    feature -- 
    
        discriminate
            do
                if G.conforms_to (MAMMAL) then
                    io.putstring ("you gave me a real animal")
                elseif G.conforms_to (COMPUTER_ACCESSORY) then
                    io.putstring ("Seems you don't like animals such as computers")
                else
                    io.pustring ("Still dont know what you are dealing with")
                end
            end
    
  • Oct 19
    Eiffel EWF Application standalone C Bind Error

    After starting it with F5, it seems that when I stop an EWF application (from estudio stop button) it takes up to 10 seconds to free the defined port on linux debian machine, Don't know if its only on this OS but is there a way to make it stop quicker? I always have to wait for some seconds to start it again after some corrections. enter image description here

  • Oct 18
    Eiffel: EWF_APP_EXECUTION (EWF application) exit function

    As there is an initialize function, is there an exit/on_exit function such as I can close my database connection into it?

  • Oct 18
    Eiffel: is there a way to print colorized characters into a terminal (console)

    Trying to write some logger enhancements I'd like to deal with ANSI codes interpretation, and it seems that it's not working with the standard io.putstring method neither with print I wonder there is a way to do something such as

    echo -e "\u001B[31mSome_red_txt" in bash

    Seems other languages can do it but I can't in Eiffel.

  • Oct 17
    Eiffel: once function has generic or anchored result. Trying to create constants

    I'm trying to create some terminal logging colors to be able to see clearer my errors. Doing that it seems to me obvious that I'd have to create constants like followings. As I don't want to create an instance each time I call my constant, it makes sense for me to do something like that, but the compiler doesn't seem to have the same conception as me...

    A once function has generic or anchored result what is an anchored result?

    As the compiler has always the last word and me the forelast, why am I wrong and is he right??

    class
        TERMINAL_COLOR
    
    create
        make
    
    feature -- Initialization
    
        make (a_fg: like foreground; a_bg: like background)
            do
                foregound := a_fg
                background := a_bg
            end
    
    feature -- Status report
    
        foreground: INTEGER
    
        background: INTEGER
    
    feature -- Colors
    
        Black: like Current
            once -- compiler doesn't agree with me
                create Result.make (30, 40)
            ensure
                instance_free: class
            end
    
    end
    
  • Oct 17
    Eiffel: how do I create and use an UTIL class, or "call static method from class"

    as my post describes it, I'd like to create an UTIL class with a never_both function.

    class
        UTIL
    
    create
        default_create
    
    feature -- could be in class BOOLEAN
    
        double_implies, reversible_implies, never_both (a, b: BOOLEAN): BOOLEAN
                -- Into boolean class with never_with
            do
                if a and b then
                    Result := False
                else
                    Result := True
                end
            end
    
    end
    

    When I use it

    invariant
        never_both: {UTIL}.never_both (attached last_error, attached last_success_message)
    

    the compiler complains about a VUNO error

    never_both used in the non-object call is not a class feature.

    I saw 2 notations about objects creating - {UTIL}.never_both (a, b) - ({UTIL}).never_both (a, b)

    Whats the difference between them?

    How to create an application wide (could be even world wide once if you want!) object for the use of this UTIL if possible in Eiffel?!

    I know this is a TUPLE of questions so I put them in Bold

  • Oct 17
    Alias and multiple names for attributes

    Defining various names for a same feature seems possible in Eiffel, what for the attributes?

    Is it possible to name an attribute like:

    background, bk: COLOR
    foreground, fg: COLOR
    

    If not why?

  • Oct 12
    Eiffel ODBC how to get answer from database

    I'm trying to get an answer from ODBC postgresql database when doing a simple

    DELETE * from some_table

    with following code, I'm unable to get the DELETE 1 classical answer? affected_row_count was my guess but seems its not is_affected_row_count_supported. I have the same problem with inserts...

    delete_entity (a_primary_key: INTEGER_64)
            -- Delete from given primary_key object
        require
            valid_db_connection: attached db_connection.base_update
                        and attached db_connection.session_control
        local
            l_void: like item
        do
            if attached db_connection.base_update as l_base_update
                    and then attached db_connection.session_control as l_session_control then
                l_base_update.modify (delete_from_primary_key_query(a_primary_key))
                if l_base_update.is_ok then
                    last_success_message := "Entity with ID " + a_primary_key.out + " deleted from DB successfully"
                    if l_base_update.is_affected_row_count_supported then
                        check
                            only_one_affected_row: l_base_update.affected_row_count = 1
                        end
                        if attached last_success_message as l then
                            l.append (" affected rows:" + l_base_update.affected_row_count.out )
                        end
                    end
                    if attached last_success_message as l then logger.write_information (l) end
                else
                    create {INSERT_ERROR} last_error.make ("last delete did not work: " + l_base_update.error_message_32)
                end
            end
        end
    
  • Oct 12
    Eiffel: Unknown identifier on attached check into require statement
        require
            valid_item: attached item as l_i and then l_i.valid_for_insert or l_i.valid_for_update
    

    why do I have an unknown identifier here with l_i??!!!

  • Oct 12
    Eiffel: classical typecasting switch structure with attached and inspect

    What is the best practice to do something such as

    local
        l_pet: ANIMAL
    do
        l_pet := catch_it_from_the_sky
        inspect l_pet
        when attached {DOG} l_pet as l_dog
            l_dog.eat (meat)
        when attached {FISH} l_pet as l_fish
            l_fish.eat (plants)
        else
            io.put_string ("Strange animal how do I feed him???")
        end
    do
    

    the compiler is complaining with the attached after when...

    Update: why such a need?

    because it just happened me to mess up with repeated copy-paste which is what a language tries to help avoiding. In the above case, the l_pet is written one time, with a N times if/else I'd have to write it as much times as ifs...

  • Oct 12
    Eiffel: is there a way to express a double implies clause in eiffel?

    Like double bind in psychology, is there a way to tell that one expression implies another and reversely?

    valid_last_error: attached last_error implies not attached last_success_message
    valid_last_success_message: attached last_success_message implies not attached last_error
    

    would be something like

    valid_last_error: attached last_error double_binded_not attached last_success_message
    

    which could be equivalent to

    valid_last_error: attached last_error never_with attached last_success_message
    
    • T stands for True boolean expression
    • F for False
    • R for Result

    implies (a, b: BOOLEAN): BOOLEAN

    a b R
    T T T
    T F F
    F T T
    F F T
    

    and (a, b: BOOLEAN): BOOLEAN

    a b R
    T T T
    T F F
    F T F
    F F F
    

    or (a, b: BOOLEAN): BOOLEAN

    a b R
    T T T
    T F T
    F T T
    F F F
    

    xor (a, b: BOOLEAN): BOOLEAN

    a b R
    T T F
    T F T
    F T T
    F F F
    

    double_implies (a, b: BOOLEAN): BOOLEAN

    a b R
    T T F
    T F T
    F T T
    F F T
    

    as a maybe more explaining example (more known) instead of writing

    invalid_index_implies_off: index < 1 implies off
    off_implies_invalid_index: off implies index < 1
    

    we could write:

    index_coherent_with_off: index < 1 never_both off
    

    which would just add a function to BOOLEAN class such as

    alias never_with, alias reversible_implies (v: like Current): like Current
        do
            if Current and v then
                Result := False
            else
                Result := True
            end
        end
    

    Hope now everybody got my point... I don't know if there is such arithmetic operator.

    We could extend it for a variable number of parameters

  • Oct 11
    Eiffel: escaping characters

    I'm looking for escaping characters for a DB query. As it is a complex mechanism (and also could be hacked), it seems obvious I don't want to rewrite it...

    I saw that in the JSON_STRING class there is something for escaping STRING_8 (unescape_to_string_8) is there something comparable for DB Strings (need for postgresql)?

  • Oct 11
    Eiffel: Is there a way to specify various types for a parameter

    Is there a way to restrict the conformance of a type to be a collection of types?

    Let me explain by example:

    give_foo (garbage: ANY): STRING
        do
            if attached {STRING} garbage as l_s then
                Result := l_s
            elseif attached {INTEGER} garbage as l_int then
                Result := l_int.out
            elseif attached {JSON_OBJECT} garbage as l_int then
                Result := l_int.representation
            elseif attached {RABBIT} garbage as l_animal then
                Result := l_animal.name + l_animal.color
            else
                Result := ""
                check
                    unchecked_type_that_compiler_should_be_able_to_check_for_me: False
                end
            end
        end
    

    Couldn't I do something like (like a convert function could do)

    give_foo (garbage: {STRING, INTEGER, JSON_OBJECT, RABBIT}): STRING
        do
            if attached {STRING} garbage as l_s then
                Result := l_s
            elseif attached {INTEGER} garbage as l_int then
                Result := l_int.out
            elseif attached {JSON_OBJECT} garbage as l_int then
                Result := l_int.representation
            elseif attached {RABBIT} garbage as l_animal then
                Result := l_animal.name + l_animal.color
            else
                Result := ""
                check
                    unchecked_type_that_compiler_should_be_able_to_check_for_me: False
                end
            end
        end
    

    or something like

    not_garbage_hash_table: HASH_TABLE[{INTEGER, STRING, ANIMAL}, STRING]
    
  • See more ...