Prev: scope of implied do-variable and initialize values
Next: Expressive programming for computational physics in Fortran 95+ (paper)
From: Louis Krupp on 2 Jun 2010 03:41 On 6/1/2010 9:40 PM, Ron Shepard wrote: > In article<5KWdnQAwhvwt9ZjRnZ2dnUVZ_g6dnZ2d(a)indra.net>, > Louis Krupp<lkrupp_nospam(a)indra.com.invalid> wrote: > >> >> Use modules. The compiler will convert arguments as necessary > > No, nothing is converted. > >> (someone >> want to verify this?) > > You must be thinking of some other language. Other languages do > sometimes do silent conversions to match arguments. So reals aren't truncated to integers? Louis
From: dpb on 2 Jun 2010 08:01 Louis Krupp wrote: > On 6/1/2010 9:40 PM, Ron Shepard wrote: .... >> You must be thinking of some other language. Other languages do >> sometimes do silent conversions to match arguments. > > So reals aren't truncated to integers? In argument lists? No, a REAL in a CALL statement for a routine expecting an INTEGER will generate a mismatched argument type error (in the module during compilation) and a mismatched call if forced to link outside of one where a compiler may not be able to tell of the mismatch. --
From: mecej4 on 2 Jun 2010 08:24 dpb wrote: > Louis Krupp wrote: >> On 6/1/2010 9:40 PM, Ron Shepard wrote: > ... >>> You must be thinking of some other language. Other languages do >>> sometimes do silent conversions to match arguments. >> >> So reals aren't truncated to integers? > > In argument lists? No, a REAL in a CALL statement for a routine > expecting an INTEGER will generate a mismatched argument type error (in > the module during compilation) and a mismatched call if forced to link > outside of one where a compiler may not be able to tell of the mismatch. > > -- To add to what dpb said: If the expected INTEGER is used as a subscript but a real (or another mismatched type) was passed instead, a prompt SEGFAULT may be expected. -- mecej4
From: Louis Krupp on 2 Jun 2010 08:54 On 6/2/2010 6:24 AM, mecej4 wrote: > dpb wrote: > >> Louis Krupp wrote: >>> On 6/1/2010 9:40 PM, Ron Shepard wrote: >> ... >>>> You must be thinking of some other language. Other languages do >>>> sometimes do silent conversions to match arguments. >>> >>> So reals aren't truncated to integers? >> >> In argument lists? No, a REAL in a CALL statement for a routine >> expecting an INTEGER will generate a mismatched argument type error (in >> the module during compilation) and a mismatched call if forced to link >> outside of one where a compiler may not be able to tell of the mismatch. >> >> -- > To add to what dpb said: If the expected INTEGER is used as a subscript but > a real (or another mismatched type) was passed instead, a prompt SEGFAULT > may be expected. Likely (given the format of IEEE floating point, for example), but not necessarily (if a high virtual address plus garbage with high-order bits turned on wrap around to a low, valid virtual address). The same thing would happen in that Other Language with which I'm more familiar. Louis
From: Ron Shepard on 2 Jun 2010 14:19
In article <8-GdnX9H3cm8lpvRnZ2dnUVZ_qudnZ2d(a)indra.net>, Louis Krupp <lkrupp_nospam(a)indra.com.invalid> wrote: > > You must be thinking of some other language. Other languages do > > sometimes do silent conversions to match arguments. > > So reals aren't truncated to integers? No. Actually I can't think of any situation offhand where reals are truncated to integers. In some contexts, such as mixed arithmetic, integers are silently converged to reals, but I can't think of any situations where the reverse occurs. And especially for subprogram arguments, no conversion is ever done silently, not even between different kinds of the same type, much less between different types. $.02 -Ron Shepard |