Forum
- https://rss.app/feeds/FNptyNlLRpG6MAV1.xml
- https://stackoverflow.com/feeds/tag?tagnames=eiffel&sort=newest
-
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
-
2020, Jun 17eiffel: type is based on unknown class (even when visible into libraries)
Trying to include a library I just created I'm unable to have the Class available even if it appears into the libraries on the group view of eiffel studio
../thirdparty/moon_time/sunriset_lib.ecf
<?xml version="1.0" encoding="ISO-8859-1"?> <system xmlns="http://www.eiffel.com/developers/xml/configuration-1-21-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-21-0 http://www.eiffel.com/developers/xml/configuration-1-21-0.xsd" name="sunriset" uuid="6E7AC452-4513-4BB4-9F04-A1ABCBCC1BE3" library_target="sunriset"> <target name="sunriset"> <root all_classes="true"/> <file_rule> <exclude>/CVS$</exclude> <exclude>/EIFGENs$</exclude> <exclude>/\.git$</exclude> <exclude>/\.svn$</exclude> </file_rule> <option warning="warning" manifest_array_type="mismatch_warning"> <assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/> </option> <setting name="console_application" value="true"/> <setting name="total_order_on_reals" value="false"/> <setting name="dead_code_removal" value="feature"/> <library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/> <library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/> <cluster name="src" location=".\src\" recursive="true"/> </target> <target name="sunriset_tests" extends="sunriset"> <root class="APPLICATION" feature="make"/> <option warning="warning"> <assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/> </option> <setting name="console_application" value="true"/> <library name="testing" location="$ISE_LIBRARY\library\testing\testing.ecf"/> <cluster name="test" location=".\testing\" recursive="true"/> </target> </system>
main-raspi-app.ecf
<?xml version="1.0" encoding="ISO-8859-1"?> <system xmlns="http://www.eiffel.com/developers/xml/configuration-1-21-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-21-0 http://www.eiffel.com/developers/xml/configuration-1-21-0.xsd" name="main_raspi_app" uuid="CC76847A-99AA-4FAE-A27F-CFBA76A914AF"> <target name="raspi_data_visitor"> <root class="RASPI_DATA_VISITOR_APP" feature="make"/> <file_rule> <exclude>/CVS$</exclude> <exclude>/EIFGENs$</exclude> <exclude>/\.git$</exclude> <exclude>/\.svn$</exclude> </file_rule> <option warning="warning" manifest_array_type="mismatch_warning"> <assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/> </option> <setting name="console_application" value="true"/> <setting name="executable_name" value="raspi_data_visitor"/> <setting name="dead_code_removal" value="feature"/> <library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/> <library name="json" location=".\..\thirdparty\json\library\json.ecf" readonly="false"/> <library name="sit-platform" location=".\..\sit-platform\sit_platform_lib.ecf" readonly="false"/> <library name="sunriset" location=".\..\thirdparty\moon_time\sunriset_lib.ecf" readonly="false"/> <cluster name="src" location=".\src\" recursive="true"/> </target> <target name="raspi_data_generator" extends="raspi_data_visitor"> <root class="RASPI_DATA_GENERATOR_APP" feature="make"/> </target> </system>
-
2020, Jun 16eiffel type conformance and attachement check not working
Trying to solve one of the SCOOP consequences with
make_from_separate
I'm running into an issue where at runtime types seem to be the same and won't pass theattached
statement.non_separate_from_any
non_separate_from_any, any_from_separate (v: separate ANY): ANY local l_array: ARRAY[detachable ANY] l_res_ll_arr_det_any: LINKED_LIST[ARRAY[detachable ANY]] l_arr_det_str: ARRAY[detachable STRING] do if attached {REAL} v as l_v then Result := l_v elseif attached {separate INTEGER_32_REF} v as l_v then Result := l_v.as_integer_32 elseif attached {INTEGER} v as l_v then Result := l_v elseif attached {separate STRING} v as l_v then create {STRING} Result.make_from_separate (l_v) elseif attached {separate STRING_32} v as l_v then create {STRING_32} Result.make_from_separate (l_v) elseif attached {separate LINKED_LIST[separate ARRAY[detachable ANY]]} v as l_v then create l_res_ll_arr_det_any.make across l_v is l_list_item_sep loop create l_array.make_empty separate l_list_item_sep as l_list_item_sep_tmp do across l_list_item_sep_tmp as l_array_item_non_sep loop if attached l_array_item_non_sep as l_any_sep then l_array.put (non_separate_from_any (l_any_sep), l_array_item_non_sep.cursor_index) else l_array.put (Void, l_array_item_non_sep.cursor_index) end end end l_res_ll_arr_det_any.extend (l_array) end Result := l_res_ll_arr_det_any elseif attached {separate ARRAY[detachable STRING]} v as l_v then create l_arr_det_str.make_empty across l_v as l_s_sep loop if attached l_s_sep.item as l_s_sep_att then l_arr_det_str.put (create {STRING}.make_from_separate (l_s_sep_att), l_s_sep.cursor_index) else l_arr_det_str.put (Void, l_s_sep.cursor_index) end end Result := l_arr_det_str else check implement_me: False then do_nothing end end ensure instance_free: Class end
Variables and statements with screenshot
UPDATE 20200616
Declarations are following:
DB_TUPLE_COL_NAMES -> items: ARRAY[STRING] DEFAULT_DB_ACTION -> column_names: separate like {DB_TUPLE_COL_NAMES}.items DEFAULT_DB_ACTION -> make_from_separate (other: separate like Current)
At runtime I got a
other.column_names -> at runtime: ARRAY[detachable STRING]
How can that be!!! thats the reason of my implementation of
any_from_separate
withl_arr_det_str
-
2020, Jun 16eiffel: semantic of ANY default
Surprised that Default in class
ANY
is frozen and without implementation???, what is the semantic for this function??Class ANY
frozen default: detachable like Current -- Default value of object's type do end
My intention was to define a
default: like Current
or maybe detachable which returns the default value for currentClass
, so redefine it... -
2020, Jun 12The class inherits two different generic derivations of the same class
What is the proper way of precising the type of an iterable through inheritence.
as inherit FOO[like babar] is not alowed
FOO
class FOO inherit ITERABLE[detachable ANY] -- I know garbage but for DB_RESULT its the case feature -- Access new_cursor: ITERATION_CURSOR[like items.item] do Result := items.new_cursor end items: ARRAY[detachable ANY] end -- class FOO
BAR
class BAR inherit FOO -- I know garbage but for DB_RESULT its the case ITERABLE[STRING] -- I know garbage but for DB_RESULT its the case feature -- Access new_cursor: ITERATION_CURSOR[like items.item] do Result := items.new_cursor end items: ARRAY[STRING] end -- class FOO
-
2020, Jun 12non-compatible actual argument in feature call in collection make_from_separate
Don't understand where I'm wrong here...
class LINKED_LIST_SEP[G] inherit LINKED_LIST [G] create make, make_from_iterable, make_from_separate feature {NONE} -- Initialization make_from_separate (other: separate like Current) do default_create across other is l_item loop check attached {G} {SCOOP_UTIL}.any_from_separate (l_item) as l_v then extend (l_v) end end end end -- class
- question about ACROSS loops with exit condition
- Warnings during finilization
- RENAME, REDEFINE commenting out...again.
- MacOS installation
- Inheritance of conversions
- See more ...