by Jocelyn-Fiat (modified: 2018 Sep 05)

:: Welcome :: Forum

Eiffel related groups and forums:

Check the latest messages:

  • Mar 03
    Why does my Cecil / Eiffel code not find the 'apply' procedure in class PROCEDURE?

    I want a C routine, which is supplied with an Eiffel 'agent' to call the routine 'apply' in the class PROCEDURE.

    int c_nng_aio_set_procedure_target(void *item, EIF_OBJECT target) {
        void **pptr = (void **) (item);
        EIF_TYPE_ID type_id;    /* Eiffel type identifier for class `class_name' */
        EIF_PROCEDURE e_proc;   /* Eiffel procedure `proc_name' */
        EIF_PROCEDURE *p_proc;
        EIF_OBJECT *p_object;
        type_id = eif_type (target);
        if (type_id == EIF_NO_TYPE) {
            printf ("PROCEDURE type_id not found\n");
            return (0);
        e_proc = eif_procedure ("apply", type_id);
        if (e_proc == (EIF_PROCEDURE) 0) {
            printf ("'apply' procedure not found\n");
            return (0);
        /* Success in finding procedure address, */
        /* now store that and the target into the storage block */
        pptr[4] = e_proc;
        pptr[5] = target;
        return (1);

    My code currently prints [as above] that the 'apply' procedure is not found.

    I have ensured that 'apply' is used from within the Eiffel code [apply_check is called]:

            print ("report_completion ... OK%N")
            p: PROCEDURE
            p := agent report_completion

    Any ideas ?

  • Mar 01
    Eiffel Studio ARM Apple Silicon M1

    I am hoping to create some software with Eiffel & Eiffel Studio

    I have a Mac mini with the Apple M1 Arm Processor.

    Is there a port of EiffelStudio to native Mac M1?

    Does Eiffel Studio support native MacOS Windowing or is it still requiring Windows?

  • 2021, Sep 27
    EiffelStudio finalize with contracts enabled

    How to produce the Finalized executable with contract checking enabled? It is possible to keep the check statements intact, but can we keep all the pre/postconditions and class invariants?

    I need this for testing a computationally expensive application and frozen with contracts executable is a bit too slow in my case.

  • 2021, May 28
    Implementing a common attribute in recursive data type like TREE

    When implementing a recursive data structure like TREE, I need a common attribute per TREE, and I wonder how to implement it:

    • Adding the attribute to a TREE node, replicates the attribute for every node, not once per TREE
    • Using a once attribute, I get only one shared attribute for all TREEs, not one per TREE.

    Is there any elegant Eiffel-style solution for that?

  • 2021, May 27
    Understanding Eiffel loop variant/invariant

    I was trying to have a structure which talks himself about variants and invariants into Eiffel loops, but don't understand the variant part!

        l_array := <<1,2,30,60>>
        l_index := l_array.lower
        valid_local_index: l_array.valid_index (l_index) or l_index = l_array.upper + 1
        l_index > l_array.upper
        l_item := l_array.item (l_index)
        l_index := l_index + 1
        --l_index <= l_array.upper -- will never be false
        --l_index -- doesnt work
  • 2021, May 26
    referencing typed element of tuple

    Discovering late (used to define classes instead) TUPLES and looking through the documentation I was wondering if there is a mechanism to get the right type of a given TUPLE. The goal is both anchoring its types and avoid having to test its type before getting an item. Is there a language mechanism?

    I also found few documentation about them, maybe I'm not looking at the right place.

    For the following code I'd like to tell like tuple_items.types[1] and tuple_items.typed_item (1)

            if attached {STRING} tuple_items.item (1) as l_tuple_item_1 then
                io.put_string (l_tuple_item_1)
            if attached {DATE} tuple_items.item (1) as l_tuple_item_2 then
                io.put_string (l_tuple_item_2.out)
            - ...
    tuple_items: TUPLE[STRING, DATE, INTEGER]
            l_first: STRING -- like tuple_items.first?
            Result := [l_first, create {DATE}.make_now, 1]
  • 2021, May 25
    number of seconds since epoch in eiffel for a DATE_TIME object

    how would you calculate the number of seconds since epoch in eiffel for a DATE_TIME object?

    What is the proper way to do it with the current libraries?

  • 2021, May 24
    How can I get more information when debugging a contract violation that checks for equality

    I have the following Eiffel code. I am doing test-driven-design with contracts.

        sorter.sorted (<<1>>).is_equal (<<1>>)

    The code correctly detects that my sort returns the wrong value. However it would be nice to see what sorted returned. I can see that it is too late as is_equals consumes both values, and returns false, before the check throws the exception.

    I have seen in other testing frameworks they have a special is_equal for the test framework. That allows better feedback. e.g.

    check_equal(expected, value_under_test)

    Is there anything like this in eiffel?

  • 2021, Feb 22
    Result attached or exception

    Let's say that I have a function f which should return an attached T by calling g. However, g returns a detachable T. If g results in a Void, I want to raise an exception like this:

    f: T
        if attached g as res then
          Result := res
        (create {DEVELOPER_EXCEPTION}).raise

    In this setup EiffelStudio gives me an error VEVI: Variable is not properly set. Variable: Result at the end of f.

    Indeed, Result can be Void at the end of f but the execution should not reach the end of f in this case, an exception should have been raised.

    How can I restructure the code to achieve a similar result?

  • 2021, Feb 20
    Exit program in Eiffel

    Is there a way in Eiffel to exit a program, possible with a defined exit code like exit in C?

    In my case I would like to just end the program like exit(0) would do.

  • 2021, Jan 21
    how to retreive the value of a custom header into a WSF_REQUEST

    I'm looking how to get a custom header value from a received WSF_REQUEST. I read the docs quickly and didn't find the answer.

    'Authorization': 'Bearer my_long_token'
  • 2021, Jan 21
    rescue how to raise further or forget an exception

    How do I raise an exception further in eiffel? I have 3 cases

    1. I want to retry

              l_retries_count: INTEGER
              if l_retries_count <= 3 then
                  l_retries_count := l_retries_count + 1
    2. I want to do close db connection and ignore exception

    3. I want to do close db connection and send an email to an admin and ignore

    4. I want to close db_connection and raise the exception further, I'll put all the cases I can think about into the above code

              l_retries_count: INTEGER
              if l_retries_count <= 3 then
                  l_retries_count := l_retries_count + 1
                  log_error ("Error, retrying for " + l_retries_count.out + "th time")
                  -- raise the_created_exception_from_some_potential_failing_feature -- how do I do that?
  • 2021, Jan 04
    How to inherit from HASH_TABLE in Eiffel?

    I want to make a derived class of HASH_TABLE which implements a few additional features. I tried implementing it like this:

                make as make_2
        make (capacity_ : INTEGER)

    I get this error:

    Error: Creation instruction uses call to improper feature.
    Feature name: make_2 (n: INTEGER_32)
    Line: 1156
    ->      create Result.make (n)
            if object_comparison then

    I don't understand why. If I do the same with inherit ARRAY[G], then it works fine.

  • 2021, Jan 01
    How to compile using EiffelStudio? VD43 Precompiled file is missing or unreadable (...)/driver.exe - External C compilation failed

    After installing EiffelStudio I can't compile and run any project because I always get VD43 warning and C Compiler Error.

    2   VD43    Precompiled file is missing or unreadable. File 'c:\users\username\documents\eiffel user files\19.05\precomp\spec\win64\EIFGENs\base-scoop-safe\W_code\msc_vc140\driver.exe'.   
    1   C Compiler Error    Please review the External Compilation output of the Outputs Tool.              
        Error code: C Compiler Error
    Error: External C/C++ compilation failed.
    What to do: Check the external C/C++ compilation for details.
    Please review the External Compilation output of the Outputs Tool.  

    I found this page: The key ISE_C_COMPILER must be additionally defined in order for EiffelStudio to work at all. But how does one "Tell EiffelStudio to use Visual Studio 2017-compatible libraries"? I tried setting it as an environment variable, and changing the compile_library.bat and esvars.bat, so that in every place it's set ISE_C_COMPILER=msc_vc140. I also added variable ISE_C_COMPILER - msc_vc140 on the EiffelStudio GUI, under Project->Project Settings->Target:project->Advanced->Variables

    I deleted all the projects and the precomp folder. I ran espawn -l just to verify that I have the good c++ compiler:

    Available C/C++ compilers:
       VC160:  Microsoft Visual Studio 2019 VC++ (19.0)
       VC150:  Microsoft Visual Studio 2017 VC++ (15.0)

    To me it seems that I installed everything and I set every variable but it still gives me the same warning and error.

  • 2020, Dec 18
    Strategy to reuse created DB_SERVICES and other instances into an EWF_APP by thread

    Into my EWF_APP[EWF_APP_EXECUTION] the EWF_APP_EXECUTION inherits from WSF_FILTERED_ROUTED_EXECUTION defining setup_router.

    To be able to access informations globally by thread (as far as I understand the implementation also SCOOP region in this case), I have defined a {MY_APPLICATION_ENVIRONMENT}.app_instance which is once (by default, thread). This app_instance as a handlers: LINKED_LIST[MY_HANDLER] which is also a once and by that mecanism I'm able to access a handler instance to get some polymorphic item_prototype I reuse into my business.

    I also do the same mecanism with db_services: LINKED_LIST[DB_SERVICE[DB_ENTITY]] to be able to get a DB_SERVICE from its DB_ENTITY name.

    With the above mecanism so far, only into the {EWF_APP_EXECUTION}.setup_router I create the db services, handlers, and extend the thread app_instance.

    I figured out that the setup_router being called on each request, my handlers and db_services collections into {MY_APPLICATION_ENVIRONMENT}.app_instance grows up infinitly causing memory leaks.

    What would be the best strategy on this case? is it doable on this context as the router seems to be recreated on every request to setup the router with the existing handlers?

    Hoping I made me clear enough...

  • 2020, Dec 18
    How to enable debug into estudio

    I tried to enable the debug syntax into estudio without afording it. In this case it is from a library and it doesnt enter into the

         io.put_string ("any debug statement here")

    What's wrong with my configuration?

    enter image description here

  • 2020, Dec 17
    how could a check not been done with all assertions set to true?

    Running a debug session with estudio with all assertions set to true (I checked into cluster, common target, specific target, etc.) pass over a check assertion?

    I also tried to remove EIFGENs and recompile the whole project.

    enter image description here

  • 2020, Dec 04
    where rescue should be called in an EWF_APP to be able to close a database connection

    Inheriting from WSF_FILTERED_ROUTER_EXECUTION I redefine the clean to be able to close DB Connections. But when there is an assertion failure, I don't know where to call the clean on a rescue clause. In which feature do I have to call my clean on a rescue clause??

  • 2020, Nov 29

    When to use which type of STRING in eiffel? I saw using READABLE_STRING_GENERAL and having to l_readable_string.out' to convert it to STRING`

  • 2020, Nov 26
    how would you calculate the number of seconds since epoch in eiffel for a DATE_TIME object

    how would you calculate the number of seconds since epoch in eiffel for a DATE_TIME object?

  • 2020, Oct 16
    What is the best way to declare a constant into a class that can be redefined

    What is in eiffel the best way to have a constant which can be redefined?

    • class A => color: STRING = "green"
    • color B inherit A => cannot redefine

    while having a function which only returns "green" or "blue" needs the string to be created again, performance problem or doesnt matter?

    As far as I understood, the onces cannot be redeclared...

  • 2020, Aug 27
    eiffel: cluster has two classes with the same name

    How to deal with cluster has two classes with the same name with eiffel studio?

    when I want to choose between 2 versions? Where can I find documentation about that?

    enter image description here

    Think that there is a trick with sources->renaming io

  • 2020, Aug 11
    eiffel: a statement for explicitly executing code when assertions are on

    Sometimes the checks and contract constructions need an elaboration which wants to be avoided when assertions removed to improve performances and avoid doing useless things with the "only" work of the compiler. I refer for ex. to job in loops checks or other things. Sometimes having to build a function or having to think how to build it without being executed when assertions are on goes away of the intuitive way of the contract and its sense. I refer particularly to the check structure

    Is there a way to do something such as

    if checks_are_enabled then
        do check stuff here
    if checks_are_enabled then
        do other check stuff here
  • 2020, Jul 01
    How do I get agents to work in {ARRAY}.do_if in Eiffel?

    I am trying to iterate an array in Eiffel. And select some elements, using do_if.

    What I have tried.

    my_method (list:ARRAY[INTEGER])
            low : ARRAYED_LIST[INTEGER]
            piv : INTEGER
        create low.make(0)
        --works for all, but not what I need
        list.do_all ( agent low.extend )
        --I can't get these to work
        list.do_if ( agent low.extend, agent piv > ? )
        list.do_if ( agent low.extend, agent piv.is_greater_equal (?) )
        list.do_if ( agent low.extend, agent piv.is_greater_equal )
        list.do_if ( agent low.extend, agent (v:INTEGER):BOOLEAN do Result := v<piv end )

    I know why the last one does not work (piv is in outer scope), but not how to fix. I don't know why the others don't work.

    Version = EiffelStudio 19.5 ( GPL Edition - linux-x86-64)

  • 2020, Jun 19
    eiffel across an_iterable as vs is

    I didn't find the documentation about the difference between is and as

    I'd like to implement an iterator something similar to this MAP, I'd like to know what TYPE is returned with the is keyword and with the as one.

    • I think the is will be the item of the ITERATION_CURSOR [G] class
    • Does the as return an ITERATION_CURSOR [G] which would be like {ITERABLE}.new_cursor of ITERABLE[G]?
  • See more ...