Two questions

chrs7777

Two questions

Reply Threaded More More options
Print post
Permalink
I have written a newer version of a library for interfacing to GMP and MPFR.
While testing I tried this:

print ("%N%N"); print (({MPFR}).has_default); print ("%N%N")

This line prints "False".  I don't know why this is as the MPFR class has
`default_create' defined.

My other question is about this query from ANY:


 frozen default: detachable like Current

   -- Default value of object's type
  do
  end

As this query is frozen I am wondering about is purpose.

Regards
Chris Saunders

chrs7777

Re: Two questions

Reply Threaded More More options
Print post
Permalink
Made a spelling error that makes the second question difficult to
understand.  Here are the questions again with the spelling error corrected:

I have written a newer version of a library for interfacing to GMP and MPFR.
While testing I tried this:

print ("%N%N"); print (({MPFR}).has_default); print ("%N%N")

This line prints "False". I don't know why this is as the MPFR class has
`default_create' defined.

My other question is about this query from ANY:

frozen default: detachable like Current

-- Default value of object's type
do
end

As this query is frozen I am wondering about is purpose.

Regards
Chris Saunders




From: Chris Saunders
Sent: Friday, July 17, 2009 6:03 PM
To: Eiffel Software
Subject: [eiffel_software] Two questions


  I have written a newer version of a library for interfacing to GMP and
MPFR.
While testing I tried this:

print ("%N%N"); print (({MPFR}).has_default); print ("%N%N")

This line prints "False". I don't know why this is as the MPFR class has
`default_create' defined.

My other question is about this query from ANY:

frozen default: detachable like Current

-- Default value of object's type
do
end

As this query is frozen I am wondering about is purpose.

Regards
Chris Saunders


 

Peter Gummer-2

Re: Two questions

Reply Threaded More More options
Print post
Permalink
On 18/07/2009, at 10:35, Chris Saunders wrote:

> My other question is about this query from ANY:
>
> frozen default: detachable like Current
>
> -- Default value of object's type
> do
> end
>
> As this query is frozen I am wondering about is purpose.


It takes advantage of one of the great things about Eiffel, namely,  
that local variables are initialised to the type's default value. If  
it's a reference type, then the default value is Void; if it's an  
INTEGER, then the default value is 0; if it's a BOOLEAN, then the  
default value is False; and so on.

So this function simply returns the default value of the current  
object's type.

- Peter Gummer
chrs7777

Re: Two questions

Reply Threaded More More options
Print post
Permalink
Thanks very much Peter.  I'm going to repeat the first part of the question
although I think your answer partially addressed it.

My class MPFR is a reference type which, I think, explains why `print
(({MPFR}).has_default)' returns "False" - please correct me if this is
wrong.  In my project settings I have Are types attached by default? set to
True and Void safety set to Complete void safety.  I thought that this would
cause ({MPFR}).has_default to return true as class MPFR does have
`default_create' as a creation routine.

Regards
Chris Saunders

From: Peter Gummer
Sent: Friday, July 17, 2009 9:14 PM
To: [hidden email]
Subject: Re: [eiffel_software] Two questions


  On 18/07/2009, at 10:35, Chris Saunders wrote:

> My other question is about this query from ANY:
>
> frozen default: detachable like Current
>
> -- Default value of object's type
> do
> end
>
> As this query is frozen I am wondering about is purpose.

It takes advantage of one of the great things about Eiffel, namely,
that local variables are initialised to the type's default value. If
it's a reference type, then the default value is Void; if it's an
INTEGER, then the default value is 0; if it's a BOOLEAN, then the
default value is False; and so on.

So this function simply returns the default value of the current
object's type.

- Peter Gummer

 

Emmanuel Stapf

RE: Two questions

Reply Threaded More More options
Print post
Permalink
In reply to this post by chrs7777
> This line prints "False". I don't know why this is as the MPFR class has
> `default_create' defined.

The result of this query has nothing to do with the presence of `default_create'
as a creation procedure. It yields True for expanded types and detachable types,
False otherwise.
 
Regards,
Manu

------------------------------------------------------------------------  
Eiffel Software
805-685-1006
http://www.eiffel.com       
Customer support: http://support.eiffel.com       
User group: http://groups.eiffel.com/join       
------------------------------------------------------------------------