Re: safety model in D

2009-11-05 Thread Leandro Lucarella
dsimcha, el 6 de noviembre a las 02:13 me escribiste: > == Quote from Leandro Lucarella (llu...@gmail.com)'s article > > Andrei Alexandrescu, el 5 de noviembre a las 09:57 me escribiste: > > > Leandro Lucarella wrote: > > > >Andrei Alexandrescu, el 5 de noviembre a las 08:48 me escribiste: > > >

Re: safety model in D

2009-11-05 Thread dsimcha
== Quote from Leandro Lucarella (llu...@gmail.com)'s article > Andrei Alexandrescu, el 5 de noviembre a las 09:57 me escribiste: > > Leandro Lucarella wrote: > > >Andrei Alexandrescu, el 5 de noviembre a las 08:48 me escribiste: > > >>First off: _all_ languages except C, C++, and assembler are or

Re: safety model in D

2009-11-05 Thread Rainer Deyke
Andrei Alexandrescu wrote: > Rainer Deyke wrote: >> You're forgetting about all other system programming languages. Delphi. >> Also, >> many of these claims to safety are demonstrably false. > > Which? I can get Python to segfault. > Memory safety is defined formally in Pierce's book. Do you

Re: safety model in D

2009-11-05 Thread Leandro Lucarella
Andrei Alexandrescu, el 5 de noviembre a las 09:57 me escribiste: > Leandro Lucarella wrote: > >Andrei Alexandrescu, el 5 de noviembre a las 08:48 me escribiste: > >>First off: _all_ languages except C, C++, and assembler are or at > >>least claim to be safe. All. I mean ALL. Did I mention all? I

Re: safety model in D

2009-11-05 Thread Andrei Alexandrescu
Rainer Deyke wrote: Andrei Alexandrescu wrote: First off: _all_ languages except C, C++, and assembler are or at least claim to be safe. All. I mean ALL. Did I mention all? If that was some ideology that is not realistic, is extremely difficult to achieve, and ends up too painful to use, then su

Re: safety model in D

2009-11-05 Thread Rainer Deyke
Andrei Alexandrescu wrote: > First off: _all_ languages except C, C++, and assembler are or at least > claim to be safe. All. I mean ALL. Did I mention all? If that was some > ideology that is not realistic, is extremely difficult to achieve, and > ends up too painful to use, then such theories wou

Re: safety model in D

2009-11-04 Thread Rainer Deyke
Andrei Alexandrescu wrote: > Rainer Deyke wrote: >> '-safe' turns on runtime safety checks, which can be and should be >> mostly orthogonal to the module safety level. > > Runtime vs. compile-time is immaterial. The price of compile-time checks is that you are restricted to a subset of the langua

Re: safety model in D

2009-11-04 Thread Andrei Alexandrescu
Michal Minich wrote: [snip] Therefore I propose to use F safety. [snip] I think you've made an excellent case. Andrei

Re: safety model in D

2009-11-04 Thread Michal Minich
On Wed, 04 Nov 2009 14:24:47 -0600, Andrei Alexandrescu wrote: >> But efficiency is also important, and if you want it, why not move the >> code subjected to bounds checks to trusted/system module - I hope they >> are not checked for bounds in release mode. Moving parts of the code to >> trusted m

Re: safety model in D

2009-11-04 Thread Andrei Alexandrescu
Rainer Deyke wrote: Andrei Alexandrescu wrote: module name; // interface: unsafe impl.: unsafe module (system) name; // interface: safe impl.: unsafe module (safe) name; // interface: safe impl.: safe so you can call system modules (io, network...) f

Re: safety model in D

2009-11-04 Thread Rainer Deyke
Andrei Alexandrescu wrote: >> module name; // interface: unsafe impl.: unsafe >> module (system) name; // interface: safe impl.: unsafe >> module (safe) name; // interface: safe impl.: safe >> >> so you can call system modules (io, network...) from safe

Re: safety model in D

2009-11-04 Thread Andrei Alexandrescu
Michal Minich wrote: On Wed, 04 Nov 2009 13:12:54 -0600, Andrei Alexandrescu wrote: But I think there is no reason no use -no-safe compiler flag ... for what reason one would want to force safer program to compile as less safer :) Efficiency (e.g. remove array bounds checks). As I'm thinking

Re: safety model in D

2009-11-04 Thread Michal Minich
On Wed, 04 Nov 2009 13:12:54 -0600, Andrei Alexandrescu wrote: >> But I think there is no reason no use -no-safe compiler flag ... for >> what reason one would want to force safer program to compile as less >> safer :) > > Efficiency (e.g. remove array bounds checks). > >> As I'm thinking more a

Re: safety model in D

2009-11-04 Thread Leandro Lucarella
Michal Minich, el 4 de noviembre a las 18:58 me escribiste: > As I'm thinking more about it, I don't see any reason to have any > compiler flag for safety at all. That was exacly my point. -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---

Re: safety model in D

2009-11-04 Thread Andrei Alexandrescu
Michal Minich wrote: On Wed, 04 Nov 2009 14:03:42 -0300, Leandro Lucarella wrote: I think safe should be the default, as it should be the most used flavor in user code, right? What about: module s; // interface: safe impl.: safe module (trusted) t; // interface: safe imp

Re: safety model in D

2009-11-04 Thread Michal Minich
On Wed, 04 Nov 2009 14:03:42 -0300, Leandro Lucarella wrote: > I think safe should be the default, as it should be the most used flavor > in user code, right? What about: > > module s; // interface: safe impl.: safe > module (trusted) t; // interface: safe impl.: unsafe > m

Re: safety model in D

2009-11-04 Thread jpf
Andrei Alexandrescu wrote: > jpf wrote: >> You may want to have a look at the CoreCLR security model (that's used >> by silverlight / moonlight). It's quite similar to what you've proposed. >> http://www.mono-project.com/Moonlight2CoreCLR#Security_levels > > I don't have much time right now, but h

Re: safety model in D

2009-11-04 Thread Andrei Alexandrescu
Jesse Phillips wrote: Andrei Alexandrescu Wrote: Jesse Phillips wrote: On Tue, 03 Nov 2009 23:13:14 -0600, Andrei Alexandrescu wrote: I think the only real option is to have the importer decide if it is trusted. That can't work. I can't say that stdc.stdlib is trusted no matter how hard I t

Re: safety model in D

2009-11-04 Thread Andrei Alexandrescu
Don wrote: Andrei Alexandrescu wrote: Don wrote: Andrei Alexandrescu wrote: Don wrote: Andrei Alexandrescu wrote: module(safe) is not a comment. We need three types of modules because of the interaction between what the module declares and what the command line wants. Let's assume the d

Re: safety model in D

2009-11-04 Thread Andrei Alexandrescu
jpf wrote: Andrei Alexandrescu wrote: How can we address that? Again, I'm looking for a simple, robust, extensible design that doesn't lock our options. Thanks, Andrei You may want to have a look at the CoreCLR security model (that's used by silverlight / moonlight). It's quite similar to wh

Re: safety model in D

2009-11-04 Thread Leandro Lucarella
Andrei Alexandrescu, el 4 de noviembre a las 08:16 me escribiste: > Michal Minich wrote: > >Hello Michel, > > > >>module (system) name; // interface: unsafe impl.: unsafe > >>module (safe) name; // interface: safe impl.: safe > > > >I thought that first (unsafe-unsafe) case

Re: safety model in D

2009-11-04 Thread Jesse Phillips
Andrei Alexandrescu Wrote: > Jesse Phillips wrote: > > On Tue, 03 Nov 2009 23:13:14 -0600, Andrei Alexandrescu wrote: > > > >>> I think the only real option is to have the importer decide if it is > >>> trusted. > >> That can't work. I can't say that stdc.stdlib is trusted no matter how > >> hard

Re: safety model in D

2009-11-04 Thread Don
Andrei Alexandrescu wrote: Don wrote: Andrei Alexandrescu wrote: Don wrote: Andrei Alexandrescu wrote: module(safe) is not a comment. We need three types of modules because of the interaction between what the module declares and what the command line wants. Let's assume the default, no-f

Re: safety model in D

2009-11-04 Thread jpf
Andrei Alexandrescu wrote: > How can we address that? Again, I'm looking for a simple, robust, > extensible design that doesn't lock our options. > > > Thanks, > > Andrei You may want to have a look at the CoreCLR security model (that's used by silverlight / moonlight). It's quite similar to wha

Re: safety model in D

2009-11-04 Thread Andrei Alexandrescu
Leandro Lucarella wrote: Walter Bright, el 3 de noviembre a las 16:21 me escribiste: Andrei Alexandrescu wrote: Sketch of the safe rules: \begin{itemize*} \item No @cast@ from a pointer type to an integral type and vice versa replace integral type with non-pointer type. \item No @cast@ bet

Re: safety model in D

2009-11-04 Thread Andrei Alexandrescu
Leandro Lucarella wrote: Andrei Alexandrescu, el 3 de noviembre a las 17:54 me escribiste: Leandro Lucarella wrote: Andrei Alexandrescu, el 3 de noviembre a las 16:33 me escribiste: SafeD is, unfortunately, not finished at the moment. I want to leave in place a stub that won't lock our optio

Re: safety model in D

2009-11-04 Thread Leandro Lucarella
Walter Bright, el 3 de noviembre a las 16:21 me escribiste: > Andrei Alexandrescu wrote: > >Sketch of the safe rules: > > > >\begin{itemize*} > >\item No @cast@ from a pointer type to an integral type and vice versa > > replace integral type with non-pointer type. > > >\item No @cast@ between un

Re: safety model in D

2009-11-04 Thread Jesse Phillips
Michel Fortin Wrote: > How is this supposed to work correctly with and without the "-safe" > compiler flag? The way you define things "-safe" would make module > memory safe for use while it is not. "-safe" would cause the compiler to check if the code was safe and error out if it wasn't. Not

Re: safety model in D

2009-11-04 Thread Leandro Lucarella
Andrei Alexandrescu, el 3 de noviembre a las 17:54 me escribiste: > Leandro Lucarella wrote: > >Andrei Alexandrescu, el 3 de noviembre a las 16:33 me escribiste: > >>SafeD is, unfortunately, not finished at the moment. I want to leave > >>in place a stub that won't lock our options. Here's what w

Re: safety model in D

2009-11-04 Thread Michal Minich
Hello Don, Michal Minich wrote: Hello Michel, I'm not sure this works so well. Look at this: module memory; // unsafe interface - unsafe impl. extern (C) void* malloc(int); extern (C) void free(void*); module (system) my.system; // safe interface - unsafe impl. import memory; void test(

Re: safety model in D

2009-11-04 Thread Andrei Alexandrescu
Jesse Phillips wrote: On Tue, 03 Nov 2009 23:13:14 -0600, Andrei Alexandrescu wrote: I think the only real option is to have the importer decide if it is trusted. That can't work. I can't say that stdc.stdlib is trusted no matter how hard I try. I mean free is there! I would like to disagree

Re: safety model in D

2009-11-04 Thread Jesse Phillips
On Tue, 03 Nov 2009 23:13:14 -0600, Andrei Alexandrescu wrote: >> I think the only real option is to have the importer decide if it is >> trusted. > > That can't work. I can't say that stdc.stdlib is trusted no matter how > hard I try. I mean free is there! I would like to disagree here. void f

Re: safety model in D

2009-11-04 Thread Andrei Alexandrescu
Don wrote: Andrei Alexandrescu wrote: Don wrote: Andrei Alexandrescu wrote: module(safe) is not a comment. We need three types of modules because of the interaction between what the module declares and what the command line wants. Let's assume the default, no-flag build allows unsafe code

Re: safety model in D

2009-11-04 Thread Andrei Alexandrescu
Walter Bright wrote: Andrei Alexandrescu wrote: Sketch of the safe rules: \begin{itemize*} \item No @cast@ from a pointer type to an integral type and vice versa replace integral type with non-pointer type. \item No @cast@ between unrelated pointer types \item Bounds checks on all array acc

Re: safety model in D

2009-11-04 Thread Don
Michal Minich wrote: Hello Michel, I'm not sure this works so well. Look at this: module memory; // unsafe interface - unsafe impl. extern (C) void* malloc(int); extern (C) void free(void*); module (system) my.system; // safe interface - unsafe impl. import memory; void test() { auto i = m

Re: safety model in D

2009-11-04 Thread Michal Minich
Hello Michel, I'm not sure this works so well. Look at this: module memory; // unsafe interface - unsafe impl. extern (C) void* malloc(int); extern (C) void free(void*); module (system) my.system; // safe interface - unsafe impl. import memory; void test() { auto i = malloc(10); free(i); }

Re: safety model in D

2009-11-04 Thread Don
Andrei Alexandrescu wrote: Don wrote: Andrei Alexandrescu wrote: module(safe) is not a comment. We need three types of modules because of the interaction between what the module declares and what the command line wants. Let's assume the default, no-flag build allows unsafe code, like right

Re: safety model in D

2009-11-04 Thread Michel Fortin
On 2009-11-04 09:29:21 -0500, Michal Minich said: Hello Andrei, Michal Minich wrote: Hello Michel, module (system) name; // interface: unsafe impl.: unsafe module (safe) name; // interface: safe impl.: safe I thought that first (unsafe-unsafe) case is currently a

Re: safety model in D

2009-11-04 Thread Michal Minich
Hello Andrei, Michal Minich wrote: Hello Michel, module (system) name; // interface: unsafe impl.: unsafe module (safe) name; // interface: safe impl.: safe I thought that first (unsafe-unsafe) case is currently available just by: module name; // interface: unsafe

Re: safety model in D

2009-11-04 Thread Andrei Alexandrescu
Michal Minich wrote: Hello Michel, module (system) name; // interface: unsafe impl.: unsafe module (safe) name; // interface: safe impl.: safe I thought that first (unsafe-unsafe) case is currently available just by: module name; // interface: unsafe impl.: unsafe

Re: safety model in D

2009-11-04 Thread Andrei Alexandrescu
Don wrote: Andrei Alexandrescu wrote: SafeD is, unfortunately, not finished at the moment. I want to leave in place a stub that won't lock our options. Here's what we currently have: module(system) calvin; This means calvin can do unsafe things. module(safe) susie; This means susie commits

Re: safety model in D

2009-11-04 Thread Michal Minich
Hello Michel, module (system) name; // interface: unsafe impl.: unsafe module (safe) name; // interface: safe impl.: safe I thought that first (unsafe-unsafe) case is currently available just by: module name; // interface: unsafe impl.: unsafe separating modules to

Re: safety model in D

2009-11-04 Thread Jason House
Aelxx Wrote: > > "Andrei Alexandrescu" ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × > ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ: news:hcr2hb$dv...@digitalmars.com... > > Jesse Phillips wrote: > >> On Tue, 03 Nov 2009 17:55:15 -0600, Andrei Alexandrescu wrote: > >> > >>> There's a lot more, but there are a few useful subspaces. One is, if an >

Re: safety model in D

2009-11-04 Thread Jason House
Andrei Alexandrescu Wrote: > Jason House wrote: > > Walter Bright Wrote: > > > >> Andrei Alexandrescu wrote: > >>> Sketch of the safe rules: > >>> > >>> \begin{itemize*} \item No @cast@ from a pointer type to an > >>> integral type and vice versa > >> replace integral type with non-pointer type.

Re: safety model in D

2009-11-04 Thread Michel Fortin
On 2009-11-03 17:33:39 -0500, Andrei Alexandrescu said: So these are my thoughts so far. There is one problem though related to the last \item - there's no way for a module to specify "trusted", meaning: "Yeah, I do unsafe stuff inside, but safe modules can call me no problem". Many modules

Re: safety model in D

2009-11-04 Thread Don
Andrei Alexandrescu wrote: SafeD is, unfortunately, not finished at the moment. I want to leave in place a stub that won't lock our options. Here's what we currently have: module(system) calvin; This means calvin can do unsafe things. module(safe) susie; This means susie commits to extra che

Re: safety model in D

2009-11-04 Thread Aelxx
"Andrei Alexandrescu" ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ: news:hcr2hb$dv...@digitalmars.com... > Jesse Phillips wrote: >> On Tue, 03 Nov 2009 17:55:15 -0600, Andrei Alexandrescu wrote: >> >>> There's a lot more, but there are a few useful subspaces. One is, if an >>> entire application only u

Re: safety model in D

2009-11-04 Thread Steven Schveighoffer
On Tue, 03 Nov 2009 17:33:39 -0500, Andrei Alexandrescu wrote: SafeD is, unfortunately, not finished at the moment. I want to leave in place a stub that won't lock our options. Here's what we currently have: module(system) calvin; This means calvin can do unsafe things. module(safe) susi

Re: safety model in D

2009-11-03 Thread Andrei Alexandrescu
Jason House wrote: Walter Bright Wrote: Andrei Alexandrescu wrote: Sketch of the safe rules: \begin{itemize*} \item No @cast@ from a pointer type to an integral type and vice versa replace integral type with non-pointer type. \item No @cast@ between unrelated pointer types \item Bounds che

Re: safety model in D

2009-11-03 Thread Walter Bright
Jason House wrote: How does casting away const, immutable, or shared cause memory corruption? If I understand SafeD correctly, that's its only goal. If it does more, I'd also argue casting to shared or immutable is, in general, unsafe. They can cause memory corruption because inadvertent "teari

Re: safety model in D

2009-11-03 Thread Andrei Alexandrescu
Jesse Phillips wrote: On Tue, 03 Nov 2009 17:55:15 -0600, Andrei Alexandrescu wrote: There's a lot more, but there are a few useful subspaces. One is, if an entire application only uses module(safe) that means there is no memory error in that application, ever. Andrei Does that mean that a m

Re: safety model in D

2009-11-03 Thread Jason House
Walter Bright Wrote: > Andrei Alexandrescu wrote: > > Sketch of the safe rules: > > > > \begin{itemize*} > > \item No @cast@ from a pointer type to an integral type and vice versa > > replace integral type with non-pointer type. > > > \item No @cast@ between unrelated pointer types > > \item Bo

Re: safety model in D

2009-11-03 Thread Jesse Phillips
On Tue, 03 Nov 2009 17:55:15 -0600, Andrei Alexandrescu wrote: > There's a lot more, but there are a few useful subspaces. One is, if an > entire application only uses module(safe) that means there is no memory > error in that application, ever. > > Andrei Does that mean that a module that uses

Re: safety model in D

2009-11-03 Thread Andrei Alexandrescu
Bill Baxter wrote: On Tue, Nov 3, 2009 at 2:33 PM, Andrei Alexandrescu wrote: SafeD is, unfortunately, not finished at the moment. I want to leave in place a stub that won't lock our options. Here's what we currently have: module(system) calvin; This means calvin can do unsafe things. module

Re: safety model in D

2009-11-03 Thread Andrei Alexandrescu
Leandro Lucarella wrote: Andrei Alexandrescu, el 3 de noviembre a las 16:33 me escribiste: SafeD is, unfortunately, not finished at the moment. I want to leave in place a stub that won't lock our options. Here's what we currently have: module(system) calvin; This means calvin can do unsafe th

Re: safety model in D

2009-11-03 Thread dsimcha
== Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article > SafeD is, unfortunately, not finished at the moment. I want to leave in > place a stub that won't lock our options. Here's what we currently have: > module(system) calvin; > This means calvin can do unsafe things. > modul

Re: safety model in D

2009-11-03 Thread Nick Sabalausky
"Andrei Alexandrescu" wrote in message news:hcqb44$1nc...@digitalmars.com... > SafeD is, unfortunately, not finished at the moment. I want to leave in > place a stub that won't lock our options. Here's what we currently have: > > module(system) calvin; > > This means calvin can do unsafe things.

Re: safety model in D

2009-11-03 Thread Andrei Alexandrescu
dsimcha wrote: == Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article SafeD is, unfortunately, not finished at the moment. I want to leave in place a stub that won't lock our options. Here's what we currently have: module(system) calvin; This means calvin can do unsafe thing

Re: safety model in D

2009-11-03 Thread Andrei Alexandrescu
Nick Sabalausky wrote: module(system, trusted) calvin; ? Yah, I was thinking of something along those lines. What I don't like is that trust is taken, not granted. But then a model with granted trust would be more difficult to define. Andrei

Re: safety model in D

2009-11-03 Thread Bill Baxter
On Tue, Nov 3, 2009 at 3:54 PM, Andrei Alexandrescu wrote: > Leandro Lucarella wrote: >> >> Andrei Alexandrescu, el  3 de noviembre a las 16:33 me escribiste: >>> >>> SafeD is, unfortunately, not finished at the moment. I want to leave >>> in place a stub that won't lock our options. Here's what w

Re: safety model in D

2009-11-03 Thread Andrei Alexandrescu
Nick Sabalausky wrote: "Andrei Alexandrescu" wrote in message news:hcqc3m$1pg...@digitalmars.com... Nick Sabalausky wrote: module(system, trusted) calvin; ? Yah, I was thinking of something along those lines. What I don't like is that trust is taken, not granted. But then a model with granted

Re: safety model in D

2009-11-03 Thread Bill Baxter
On Tue, Nov 3, 2009 at 2:33 PM, Andrei Alexandrescu wrote: > SafeD is, unfortunately, not finished at the moment. I want to leave in > place a stub that won't lock our options. Here's what we currently have: > > module(system) calvin; > > This means calvin can do unsafe things. > > module(safe) su

safety model in D

2009-11-03 Thread Andrei Alexandrescu
SafeD is, unfortunately, not finished at the moment. I want to leave in place a stub that won't lock our options. Here's what we currently have: module(system) calvin; This means calvin can do unsafe things. module(safe) susie; This means susie commits to extra checks and therefore only a sub

Re: safety model in D

2009-11-03 Thread Nick Sabalausky
"Andrei Alexandrescu" wrote in message news:hcqc3m$1pg...@digitalmars.com... > Nick Sabalausky wrote: >> module(system, trusted) calvin; >> ? > > Yah, I was thinking of something along those lines. What I don't like is > that trust is taken, not granted. But then a model with granted trust > wo

Re: safety model in D

2009-11-03 Thread Leandro Lucarella
Andrei Alexandrescu, el 3 de noviembre a las 16:33 me escribiste: > SafeD is, unfortunately, not finished at the moment. I want to leave > in place a stub that won't lock our options. Here's what we > currently have: > > module(system) calvin; > > This means calvin can do unsafe things. > > mod

Re: safety model in D

2009-11-03 Thread Walter Bright
Andrei Alexandrescu wrote: Sketch of the safe rules: \begin{itemize*} \item No @cast@ from a pointer type to an integral type and vice versa replace integral type with non-pointer type. \item No @cast@ between unrelated pointer types \item Bounds checks on all array accesses \item No union