Forum
Welcome :: Forum
Eiffel related groups and forums:
- Eiffel users mailing list at http://groups.eiffel.com/
- Chat with other on https://gitter.im/EiffelSoftware/EiffelStudio
- The Eiffel Web group at https://groups.google.com/forum/#!forum/eiffel-web-framework
- see other places on the page: https://www.eiffel.org/community
Check the latest messages:
-
Mar 03Why 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]:
report_completion do print ("report_completion ... OK%N") end apply_check local p: PROCEDURE do p := agent report_completion p.apply end
Any ideas ?
-
Mar 01Eiffel 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 27EiffelStudio 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 28Implementing 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 27Understanding 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!
from l_array := <<1,2,30,60>> l_index := l_array.lower invariant valid_local_index: l_array.valid_index (l_index) or l_index = l_array.upper + 1 until l_index > l_array.upper loop l_item := l_array.item (l_index) l_index := l_index + 1 variant --l_index <= l_array.upper -- will never be false --l_index -- doesnt work end
-
2021, May 26referencing 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]
andtuple_items.typed_item (1)
use_it do if attached {STRING} tuple_items.item (1) as l_tuple_item_1 then io.put_string (l_tuple_item_1) end if attached {DATE} tuple_items.item (1) as l_tuple_item_2 then io.put_string (l_tuple_item_2.out) end - ... end tuple_items: TUPLE[STRING, DATE, INTEGER] local l_first: STRING -- like tuple_items.first? do Result := [l_first, create {DATE}.make_now, 1] end
-
2021, May 25number 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 24How 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.
check sorter.sorted (<<1>>).is_equal (<<1>>) end
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 asis_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 22Result attached or exception
Let's say that I have a function
f
which should return anattached T
by callingg
. However,g
returns adetachable T
. Ifg
results in a Void, I want to raise an exception like this:f: T do if attached g as res then Result := res else raise end end raise do (create {DEVELOPER_EXCEPTION}).raise end
In this setup EiffelStudio gives me an error
VEVI: Variable is not properly set. Variable: Result
at the end off
.Indeed, Result can be Void at the end of
f
but the execution should not reach the end off
in this case, an exception should have been raised.How can I restructure the code to achieve a similar result?
-
2021, Feb 20Exit 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 21how 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 21rescue how to raise further or forget an exception
How do I raise an exception further in eiffel? I have 3 cases
I want to retry
a_feature local l_retries_count: INTEGER do some_potential_failing_feature rescue if l_retries_count <= 3 then l_retries_count := l_retries_count + 1 retry end end
I want to do close db connection and ignore exception
a_feature do some_potential_failing_feature rescue db_connection.close end
I want to do close db connection and send an email to an admin and ignore
a_feature do some_potential_failing_feature rescue db_connection.close send_email_to_admin end
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
a_feature local l_retries_count: INTEGER do some_potential_failing_feature rescue if l_retries_count <= 3 then l_retries_count := l_retries_count + 1 log_error ("Error, retrying for " + l_retries_count.out + "th time") retry else db_connection.close send_email_to_admin -- raise the_created_exception_from_some_potential_failing_feature -- how do I do that? end end
-
2021, Jan 04How 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:
class HASH_TABLE2[G->HASHABLE] inherit HASH_TABLE[G,G] rename make as make_2 end create make feature make (capacity_ : INTEGER) do make_2(capacity_) end end
I get this error:
Error: Creation instruction uses call to improper feature. Feature name: make_2 (n: INTEGER_32) Line: 1156 do -> 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 01How 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: https://www.eiffel.org/doc/version/trunk/faq/FAQ. 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->VariablesI 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 18Strategy to reuse created DB_SERVICES and other instances into an EWF_APP by thread
Into my
EWF_APP[EWF_APP_EXECUTION]
theEWF_APP_EXECUTION
inherits fromWSF_FILTERED_ROUTED_EXECUTION
definingsetup_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). Thisapp_instance
as ahandlers: 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 aDB_SERVICE
from itsDB_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 threadapp_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 18How to enable debug into estudio
-
2020, Dec 17how could a check not been done with all assertions set to true?
-
2020, Dec 04where rescue should be called in an EWF_APP to be able to close a database connection
Inheriting from
WSF_FILTERED_ROUTER_EXECUTION
I redefine theclean
to be able to close DB Connections. But when there is an assertion failure, I don't know where to call theclean
on a rescue clause. In which feature do I have to call my clean on arescue
clause?? -
2020, Nov 29READABLE_STRING_GENERAL vs STRING
When to use which type of STRING in eiffel? I saw using
READABLE_STRING_GENERAL
and having tol_readable_string.out' to convert it to
STRING` -
2020, Nov 26how 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 16What 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 27eiffel: cluster has two classes with the same name
-
2020, Aug 11eiffel: 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
structureIs there a way to do something such as
if checks_are_enabled then do check stuff here end do_some_normal_job if checks_are_enabled then do other check stuff here end
-
2020, Jul 01How 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]) local low : ARRAYED_LIST[INTEGER] piv : INTEGER do 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 (19.05.10.3187 GPL Edition - linux-x86-64)
-
2020, Jun 19eiffel across an_iterable as vs is
I didn't find the documentation about the difference between
is
andas
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 theas
one.- I think the is will be the
item
of theITERATION_CURSOR [G]
class - Does the as return an
ITERATION_CURSOR [G]
which would belike {ITERABLE}.new_cursor
ofITERABLE[G]
?
- I think the is will be the
- See more ...