March 23, 2008 Reddit: SafeD - The Safe Subset of D | ||||
---|---|---|---|---|
| ||||
http://reddit.com/r/programming/info/6d210/comments/ |
March 23, 2008 Re: Reddit: SafeD - The Safe Subset of D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote:
>
> http://reddit.com/r/programming/info/6d210/comments/
Is this something that actually exists? Or just an idea being thrown around? Or just a marketing slogan for using D without pointers?
-bb
|
March 23, 2008 Re: Reddit: SafeD - The Safe Subset of D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bill Baxter | Bill Baxter wrote:
> Is this something that actually exists? Or just an idea being thrown around? Or just a marketing slogan for using D without pointers?
It's an idea for defining a language subset that is enforceable by the compiler.
|
March 23, 2008 Re: Reddit: SafeD - The Safe Subset of D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright schrieb:
> Bill Baxter wrote:
>> Is this something that actually exists? Or just an idea being thrown around? Or just a marketing slogan for using D without pointers?
>
> It's an idea for defining a language subset that is enforceable by the compiler.
... in other words, an upcoming compiler switch ?
I like that idea very much.
|
March 23, 2008 Re: Reddit: SafeD - The Safe Subset of D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote: > > http://reddit.com/r/programming/info/6d210/comments/ In light of this I find it rather incredible that printf still is exposed through Object. -- Lars Ivar Igesund blog at http://larsivi.net DSource, #d.tango & #D: larsivi Dancing the Tango |
March 23, 2008 Re: Reddit: SafeD - The Safe Subset of D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote: > > http://reddit.com/r/programming/info/6d210/comments/ http://www.digitalmars.com/d/2.0/safed.html A bit light on the syntax, but I completely agree with avoiding pointers whenever possible. Unchecked casts and unions are also clearly dangerous, if less so. Unfortunately, unchecked casts seem to be necessary for some purposes. It's not just efficiency, I literally don't see any way around them. (I'm considering a union to be a kind of unchecked cast.) P.S.: What is a checked cast? If I want to consider a long as an array of bytes: byte[long.sizeof] val; it ought to be safe to later consider that array of bytes as a long. But what's a safe (checked) way to do it? (I'm not talking about conversion. I don't want to end up with an array of longs.) PPS: When talking about casts or type conversions, please make it explicit whether the same bit pattern is maintained. I often read those descriptions, and realize that I can't figure out exactly what is happening. With C I was always certain that I was just telling the compiler to think about the same piece of memory differently, and that nothing actually changed. With more modern languages, a lot more magic happens under the hood, and I'm no longer as certain what's going on. I often wonder after reading the documentation whether the same bit pattern is maintained, or whether an equivalent value is produced. E.g., I've never tried casting a float to a long. What would it produce? I can't predict. I'd often prefer to deal with ulongs or ucents rather than byte arrays, but then at other times I need to address particular bytes out of that value. Because I don't really understand a cast, I just use byte arrays (well, ubyte). But it's "sloppier". Generally I'm dealing with a unitary entity, and needing to think of it as an array all the time is uncomfortable. (I'd even like a notation for dealing with particular bits, though I haven't needed that recently.) Note that this isn't a request for a change in how things act, but rather in how they are documented. I *suspect* that cast is presumed to be defined by C, and that it means "Think about they type differently, but don't change it's bit pattern", but I'm never quite certain. |
March 23, 2008 Re: Reddit: SafeD - The Safe Subset of D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote:
>
> http://reddit.com/r/programming/info/6d210/comments/
Is SafeD just a label for the programmer selectively using D features?
|
March 23, 2008 Re: Reddit: SafeD - The Safe Subset of D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Charles D Hixson | Charles D Hixson wrote:
> With C I was always certain that I was just telling the compiler to think about the same piece of memory differently, and that nothing actually changed.
Not so:
int x = (int)2.5;
Not the same bit pattern after as before (not even if it was 2.0 on the right). But maybe you're only talking about casts with pointers in them?
--bb
|
March 23, 2008 Re: Reddit: SafeD - The Safe Subset of D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars Ivar Igesund | Lars Ivar Igesund wrote:
> In light of this I find it rather incredible that printf still is exposed
> through Object.
printf would have to be removed from the safe D subset.
|
March 23, 2008 Re: Reddit: SafeD - The Safe Subset of D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Clay Smith | Clay Smith wrote:
> Is SafeD just a label for the programmer selectively using D features?
Yes, but it would also be enforced by a compiler switch.
|
Copyright © 1999-2021 by the D Language Foundation