home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.os.vms      DEC's VAX* line of computers & VMS.      264,096 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 263,793 of 264,096   
   Dan Cross to arne@vajhoej.dk   
   Re: Unsafe code blocks   
   19 Nov 25 16:12:32   
   
   From: cross@spitfire.i.gajendra.net   
      
   In article <10fig54$1n41a$3@dont-email.me>,   
   Arne Vajhøj   wrote:   
   >On 11/18/2025 2:04 PM, Arne Vajhøj wrote:   
   >> On 11/15/2025 9:16 PM, Dan Cross wrote:   
   >>>> Also note the availability of the 'Valid attribute to make sure that   
   >>>> what   
   >>>> is in the variable after the unsafe conversion is actually a valid   
   >>>> value.   
   >>>   
   >>> Sum types make this trivial:   
   >>>   
   >>>      impl SomeType {   
   >>>          fn try_from(i: i32) -> Option {   
   >>>              // if valid, return `Some(whatever`),   
   >>>              // else return `None`.   
   >>>          }   
   >>>      }   
   >> (assuming Option in Rust is what it is in other languages)   
   >>   
   >> Option and Ada Valid are somewhat different.   
   >>   
   >> Option is a way for a function/method to either return   
   >> a value or return the fact that there is no value.   
   >>   
   >> A much better way to do that than traditional   
   >> return null or -1 or whatever to indicate there   
   >> is no value.   
   >>   
   >> Ada valid attribute is a runtime check on the result from   
   >> an unsafe conversion to see if it meets the constraints   
   >> of the data type.   
   >   
   >Option is in fashion in recent years.   
      
   Algebraic data types have been used in functional languages   
   since the 1970s, starting with the "Hope" language from   
   Edinburgh.  ML took them from Hope and popularized them, and   
   they leaked into Miranda, Haskell, and OCaml from there.  Now   
   many languages support them; even C++ (`std::optional`).   
      
   Hope was first described in a paper in 1980, but the work of   
   course predated that.   
      
   That makes them about as old as VMS, and older than Ada.  In   
   other words, they've been "In Fashion" since the 70s, which as   
   far as all things fashion goes, is a pretty good run;   
   particularly considering some of the things that were popular in   
   that decade.   
      
   >There are not that many languages on VMS supporting   
   >Option.   
   >   
   >Scala does - Option[T].   
   >   
   >And Java 8 Optional is almost the same.   
      
   More's the pity.   
      
   	- Dan C.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca