EXTERNAL -> UNSAFE ?

This is a discussion on EXTERNAL -> UNSAFE ? within the modula forums in Programming Languages category; The interface to foreign function libraries e.g. written in C does not allow any checks for consistency and is therefore unsafe. Isn't it better if the compiler requests the UNSAFE flag for modules that use the <*EXTERNAL*> pragma?...

Go Back   Application Development Forum > Programming Languages > modula

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 07-08-2003, 06:48 AM
Henning Thielemann
Guest
 
Default EXTERNAL -> UNSAFE ?


The interface to foreign function libraries e.g. written in C does not
allow any checks for consistency and is therefore unsafe. Isn't it better
if the compiler requests the UNSAFE flag for modules that use the
<*EXTERNAL*> pragma?

Reply With Quote
  #2  
Old 07-09-2003, 01:15 PM
Darko
Guest
 
Default Re: EXTERNAL -> UNSAFE ?

Henning Thielemann <iakd0@cluster.urz.uni-halle.de> wrote in message news:<Pine.A42.3.96.1030708124556.49942B-100000@clustera.urz.uni-halle.de>...
> The interface to foreign function libraries e.g. written in C does not
> allow any checks for consistency and is therefore unsafe. Isn't it better
> if the compiler requests the UNSAFE flag for modules that use the
> <*EXTERNAL*> pragma?


I see your point, but I think the lack of safety resides in the module
you're calling, not in the call. Just as if you had written an unsafe
module with a safe interface: the result of the call might be unsafe,
if the programmer who wrote the module got it wrong, but the call
itself is not an unsafe operation.

- Darko
Reply With Quote
  #3  
Old 07-09-2003, 01:32 PM
E.A. Ratzer
Guest
 
Default Re: EXTERNAL -> UNSAFE ?

On 9 Jul 2003, Darko wrote:
> Henning Thielemann <iakd0@cluster.urz.uni-halle.de> wrote in message news:<Pine.A42.3.96.1030708124556.49942B-100000@clustera.urz.uni-halle.de>...
> > The interface to foreign function libraries e.g. written in C does not
> > allow any checks for consistency and is therefore unsafe. Isn't it better
> > if the compiler requests the UNSAFE flag for modules that use the
> > <*EXTERNAL*> pragma?

> I see your point, but I think the lack of safety resides in the module
> you're calling, not in the call. Just as if you had written an unsafe
> module with a safe interface: the result of the call might be unsafe,
> if the programmer who wrote the module got it wrong, but the call
> itself is not an unsafe operation.


I would agree with Darko I think - for instance if Math.i3 was unsafe,
chaos would result. The fact that you're calling it with and it returns a
sensible type (ie not ADDRESS or something) means that it should be down
to the module to be safe once the interface is declared as safe.

I do wonder whether there should be some sort of reverse process though.
For example, EXTERNAL is assumed to be UNSAFE unless you do something like
SAFE EXTERNAL. This would then allow a variety of different types of
external functions to be used. Currently I generally split things into
two and have a safe and an unsafe interface depending on the function.

Ed.

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 04:02 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.