Re: gobo/gcc error message

Eric Bezault <[email protected]> Wed, 06 Aug 2008 12:03:51 +0200
Newsgroups gmane.comp.lang.eiffel.gobo.devel
Message-ID <[email protected]>
Hi Gloria,

Müller Gloria wrote:
> I found a way to make gec produce this:
> 
> feiffel1.c: In function ‘T22c1’:
> feiffel1.c:272: warning: assignment makes integer from pointer without a cast
> 
> 
> To do this you create a class with a generic parameter e.g. like this:
> 
> 
> class
> 	BUG_REPORT_1_SHORT[G]
> 	
> create
> 	make
> 
> feature -- Initialization
> 
> 	make(first_item: G) is
> 		local
> 			tmp: INTEGER_64
> 		do
> 			tmp ?= first_item
> 		end
> 		
> end -- class
> 
> 
> Then you call make from another class, e.g. like this:
> 
> 
> 		local
> 			i: INTEGER
> 			sw: BUG_REPORT_1_SHORT[INTEGER]
> 		do
> 			create sw.make(1)
> 		end

I now fixed it in the version in SVN to have the same behavior as
ISE, and the C compilation warning should be fixed as well.

The problem was that this code should have been flagged with a
VJRV validity error according to ETL2 (this construct does not
exist anymore in ECMA Eiffel, replaced by object-tests) because
the target is expanded. I had removed this validity error checking
in Gobo because ISE also removed it a while ago, but I had forgotten
to update the code generation.

However note that the behavior in ISE (and now in Gobo) may be weird
at first. In your example, if I remplace the routine `make' by:

~~~~~~~~~~~~~~~~~~~~
	make(first_item: G) is
		local
			tmp: INTEGER_64
		do
			tmp := 2
			tmp ?= first_item
			print (tmp)
		end
~~~~~~~~~~~~~~~~~~~~

the program will print 2, and not 1 or 0. It's because ISE does not
change the value of the target when the assignment attempt fails.
Note that it would have made more sense to set the target to its
default value in that case (which would be 0 for INTEGER_64) in
order to have a behavior similar to the case of reference types
where the target is set to Void (which is nothing else than the
default value of reference types).

> Something unrelated. I wanted to time my code. Is it really that Eiffel can only measure
> time up to a precision of seconds? If I want to time my code I need at least nanoseconds.
> Any idea how to do this? Using command line "time" is inconvenient. I want to measure
> time of little code pieces not of the entire app.

You would have to find an Eiffel date/time library which supports
nanoseconds, or write one if one does not exist yet. The Gobo
date/time library is indeed limited to milliseconds. You may have
a look at ISE's EiffelTime library, but I think that it has the same
limitation when calling `make_now'.

-- 
Eric Bezault
mailto:[email protected]
http://www.gobosoft.com

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/