Jump to page: 1 29  
Page
Thread overview
[test] A D-joke?
Aug 07, 2005
Manfred Nowak
Aug 07, 2005
Hasan Aljudy
Aug 07, 2005
Derek Parnell
Aug 07, 2005
Manfred Nowak
Aug 07, 2005
Nick
Aug 07, 2005
Regan Heath
Aug 07, 2005
Derek Parnell
Aug 07, 2005
zwang
Aug 07, 2005
Derek Parnell
Aug 07, 2005
Derek Parnell
Aug 07, 2005
Nod
Aug 08, 2005
Manfred Nowak
Aug 08, 2005
Sean Kelly
Aug 08, 2005
Manfred Nowak
Aug 08, 2005
Sean Kelly
Aug 09, 2005
Manfred Nowak
Aug 08, 2005
Burton Radons
Aug 08, 2005
Manfred Nowak
Aug 09, 2005
Burton Radons
Aug 11, 2005
Alan West
OT: (was: [test] A D-joke?)
Aug 12, 2005
Manfred Nowak
Aug 09, 2005
Derek Parnell
Aug 09, 2005
Manfred Nowak
Aug 08, 2005
llothar
Aug 08, 2005
Burton Radons
Aug 08, 2005
Sean Kelly
Aug 08, 2005
Burton Radons
Aug 08, 2005
Sean Kelly
Aug 08, 2005
Manfred Nowak
Aug 09, 2005
llothar
[OT] (was: [test] A D-joke?)
Aug 11, 2005
Manfred Nowak
Aug 11, 2005
llothar
Aug 12, 2005
Manfred Nowak
Re: [OT]
Aug 11, 2005
Georg Bauhaus
Aug 12, 2005
Thomas Kühne
Aug 12, 2005
AJG
Aug 12, 2005
Thomas Kühne
Aug 09, 2005
Derek Parnell
Aug 09, 2005
Uwe Salomon
Aug 09, 2005
Uwe Salomon
Aug 09, 2005
Manfred Nowak
Aug 09, 2005
Uwe Salomon
Aug 11, 2005
Manfred Nowak
Aug 09, 2005
Manfred Nowak
Aug 09, 2005
Hasan Aljudy
Aug 07, 2005
Nick
Aug 08, 2005
Stewart Gordon
Aug 08, 2005
Derek Parnell
Aug 07, 2005
John Demme
Aug 07, 2005
Hasan Aljudy
Spec proposal (Was: Re: [test] A D-joke?)
Aug 07, 2005
Georg Wrede
Aug 08, 2005
Greg Smith
Aug 09, 2005
Hasan Aljudy
Aug 07, 2005
Sean Kelly
Aug 07, 2005
Dejan Lekic
Aug 07, 2005
Derek Parnell
Aug 08, 2005
Sean Kelly
Aug 08, 2005
Derek Parnell
Aug 07, 2005
Burton Radons
Aug 08, 2005
Sean Kelly
Aug 08, 2005
AJG
Aug 08, 2005
Regan Heath
Aug 08, 2005
Derek Parnell
Aug 08, 2005
AJG
Aug 08, 2005
Regan Heath
Aug 08, 2005
Sean Kelly
Aug 08, 2005
Greg Smith
Aug 09, 2005
Manfred Nowak
Aug 09, 2005
AJG
Aug 09, 2005
Derek Parnell
Aug 10, 2005
Greg Smith
Aug 08, 2005
Dave
Aug 08, 2005
Sean Kelly
Aug 08, 2005
Sean Kelly
Aug 08, 2005
Derek Parnell
Aug 09, 2005
Oskar
Aug 09, 2005
AJG
Aug 10, 2005
Oskar
Aug 10, 2005
AJG
Aug 12, 2005
Derek Parnell
Aug 12, 2005
Dave
August 07, 2005
1) Review this code:

void f( inout int i, inout int j){
  i= 1;
  j= 2;
}


2) Pass or Fail?

3) Explain.


-manfred
August 07, 2005
Manfred Nowak wrote:
> 1) Review this code:
> 
> void f( inout int i, inout int j){
>   i= 1;
>   j= 2;
> }
> 
> 
> 2) Pass or Fail?
> 
> 3) Explain.
> 
> 
> -manfred

I don't get it.
August 07, 2005
On Sun, 7 Aug 2005 01:05:27 +0000 (UTC), Manfred Nowak wrote:

> 1) Review this code:
> 
> void f( inout int i, inout int j){
>   i= 1;
>   j= 2;
> }

Okay, done that.

(A) Function name 'f' is not meaningful enough.
(B) Argument 'i' is not meaningful enough for the context.
(C) Argument 'j' is not meaningful enough for the context.
(D) Inconsistent spacing on lines 2 and 3. Use either
    <identifer>=<expression>;
  or
    <identfier> = <expression>;
(E) The opening brace should not be on the function declaration line.
(F) The function body lines are not indented correctly. The standard calls
for four spaces.


> 2) Pass or Fail?

Yes and no.

> 3) Explain.

I am unable to explain because I haven't the foggiest idea what you are on about. Explain *what*?

-- 
Derek Parnell
Melbourne, Australia
7/08/2005 6:15:41 PM
August 07, 2005
Derek Parnell <derek@psych.ward> wrote:

> On Sun, 7 Aug 2005 01:05:27 +0000 (UTC), Manfred Nowak wrote:
> 
>> 1) Review this code:
>> 
>> void f( inout int i, inout int j){
>>   i= 1;
>>   j= 2;
>> }
> 
> Okay, done that.
> 
> (A) Function name 'f' is not meaningful enough.
> (B) Argument 'i' is not meaningful enough for the context.
> (C) Argument 'j' is not meaningful enough for the context.
> (D) Inconsistent spacing on lines 2 and 3. Use either
>     <identifer>=<expression>;
>   or
>     <identfier> = <expression>;
> (E) The opening brace should not be on the function declaration
> line. (F) The function body lines are not indented correctly.
> The standard calls for four spaces.

Okay, you are the quality assurer and I want to implement this routine into a piece of software, that on failure cause severe harm, i.e. loss of lives or money. So I do what you want me to:

void letThem( inout int becomesOne, inout int becomesTwo)
{
    becomesOne = 1;
    becomesTwo = 2;
}

[...]
> I am unable to explain because I haven't the foggiest idea what you are on about. Explain *what*?

See above and repeat the three steps. Hint: try harder.

-manfred

August 07, 2005
The only thing I can think of is that the inout parameters are being used as out parameters, which isn't necessarily incorrect behavior.

-John Demme

On Sun, 2005-08-07 at 01:05 +0000, Manfred Nowak wrote:
> 1) Review this code:
> 
> void f( inout int i, inout int j){
>   i= 1;
>   j= 2;
> }
> 
> 
> 2) Pass or Fail?
> 
> 3) Explain.
> 
> 
> -manfred

August 07, 2005
In article <dd4hhk$30fd$1@digitaldaemon.com>, Manfred Nowak says...
>
>Okay, you are the quality assurer and I want to implement this routine into a piece of software, that on failure cause severe harm, i.e. loss of lives or money. So I do what you want me to:
>
>void letThem( inout int becomesOne, inout int becomesTwo)
>{
>    becomesOne = 1;
>    becomesTwo = 2;
>}
>
>[...]

Perhaps you're thinking of calls of the kind

int i;
letThem(i,i);

in which case i==2? This can be avoided by adding a contract, ie.

| void letThem( inout int becomesOne, inout int becomesTwo)
| out
| {
|     assert(becomesOne == 1);
|     assert(becomesTwo == 2);
| }
| body
| {
|     becomesOne = 1;
|     becomesTwo = 2;
| }

Nick


August 07, 2005
On Sun, 7 Aug 2005 08:42:28 +0000 (UTC), Manfred Nowak <svv1999@hotmail.com> wrote:
> Derek Parnell <derek@psych.ward> wrote:
>
>> On Sun, 7 Aug 2005 01:05:27 +0000 (UTC), Manfred Nowak wrote:
>>
>>> 1) Review this code:
>>>
>>> void f( inout int i, inout int j){
>>>   i= 1;
>>>   j= 2;
>>> }
>>
>> Okay, done that.
>>
>> (A) Function name 'f' is not meaningful enough.
>> (B) Argument 'i' is not meaningful enough for the context.
>> (C) Argument 'j' is not meaningful enough for the context.
>> (D) Inconsistent spacing on lines 2 and 3. Use either
>>     <identifer>=<expression>;
>>   or
>>     <identfier> = <expression>;
>> (E) The opening brace should not be on the function declaration
>> line. (F) The function body lines are not indented correctly.
>> The standard calls for four spaces.
>
> Okay, you are the quality assurer and I want to implement this
> routine into a piece of software, that on failure cause severe
> harm, i.e. loss of lives or money. So I do what you want me to:
>
> void letThem( inout int becomesOne, inout int becomesTwo)
> {
>     becomesOne = 1;
>     becomesTwo = 2;
> }

And what happens when it's called like:

int a;
letThem(a,a);

Your function should be coded as:

void letThem( inout int becomesOne, inout int becomesTwo)
out() {
    assert(becomesOne == 1);
    assert(becomesTwo == 2);
}
body {
    becomesOne = 1;
    becomesTwo = 2;
}

or similar (I can't remember the syntax - bad me)

> [...]
>> I am unable to explain because I haven't the foggiest idea what
>> you are on about. Explain *what*?
>
> See above and repeat the three steps. Hint: try harder.

I assume there is a point to this?

Regan
August 07, 2005
On Sun, 7 Aug 2005 08:42:28 +0000 (UTC), Manfred Nowak wrote:

> Derek Parnell <derek@psych.ward> wrote:
> 
>> On Sun, 7 Aug 2005 01:05:27 +0000 (UTC), Manfred Nowak wrote:
>> 
>>> 1) Review this code:
>>> 
>>> void f( inout int i, inout int j){
>>>   i= 1;
>>>   j= 2;
>>> }
>> 
>> Okay, done that.
>> 
>> (A) Function name 'f' is not meaningful enough.
>> (B) Argument 'i' is not meaningful enough for the context.
>> (C) Argument 'j' is not meaningful enough for the context.
>> (D) Inconsistent spacing on lines 2 and 3. Use either
>>     <identifer>=<expression>;
>>   or
>>     <identfier> = <expression>;
>> (E) The opening brace should not be on the function declaration
>> line. (F) The function body lines are not indented correctly.
>> The standard calls for four spaces.
> 
> Okay, you are the quality assurer and I want to implement this routine into a piece of software, that on failure cause severe harm, i.e. loss of lives or money. So I do what you want me to:
> 
> void letThem( inout int becomesOne, inout int becomesTwo)
> {
>     becomesOne = 1;
>     becomesTwo = 2;
> }
> 
> [...]
>> I am unable to explain because I haven't the foggiest idea what you are on about. Explain *what*?
> 
> See above and repeat the three steps. Hint: try harder.

Okay ...

(G) The specification does not say what to do with the passed values of the
arguments.
(H) The specification does not define if setting both values is to be
atomic; that is, either none is set or both are set, or it doesn't matter.
(J) The specification does not define what to do when the arguments refer
to the same memory location.

Should this routine be a bit more defensive, maybe along the lines of ...


void letThem( inout int becomesOne, inout int becomesTwo)
{
    int localOne;
    int localTwo;
    // Ensure the arguments reference two different integer values.
    if (RAM_Overlaps(&becomesOne, int.sizeof, &becomesTwo, int.sizeof))
    {
       throw ReferenceException( ...whatever...);
    }

    // Take a local backup of value in case the transaction fails
    localOne = becomesOne;
    localTwo = becomesTwo;

    try {
        becomesOne = 1;
        becomesTwo = 2;
    }
    catch(Object e)
    {
      // Transaction failed, so restore previous values.
      becomesOne = localOne;
      becomesTwo = localTwo;
      throw e;  // Pass exception up the tree.
    }
}

-- 
Derek Parnell
Melbourne, Australia
7/08/2005 7:31:28 PM
August 07, 2005
Derek Parnell wrote:
> On Sun, 7 Aug 2005 08:42:28 +0000 (UTC), Manfred Nowak wrote:
> 
> 
>>Derek Parnell <derek@psych.ward> wrote:
>>
>>
>>>On Sun, 7 Aug 2005 01:05:27 +0000 (UTC), Manfred Nowak wrote:
>>>
>>>
>>>>1) Review this code:
>>>>
>>>>void f( inout int i, inout int j){
>>>>  i= 1;
>>>>  j= 2;
>>>>}
>>>
>>>Okay, done that.
>>>
>>>(A) Function name 'f' is not meaningful enough.
>>>(B) Argument 'i' is not meaningful enough for the context.
>>>(C) Argument 'j' is not meaningful enough for the context.
>>>(D) Inconsistent spacing on lines 2 and 3. Use either 
>>>    <identifer>=<expression>;  or    <identfier> = <expression>;
>>>(E) The opening brace should not be on the function declaration
>>>line. (F) The function body lines are not indented correctly.
>>>The standard calls for four spaces.
>>
>>Okay, you are the quality assurer and I want to implement this routine into a piece of software, that on failure cause severe harm, i.e. loss of lives or money. So I do what you want me to:
>>
>>void letThem( inout int becomesOne, inout int becomesTwo)
>>{
>>    becomesOne = 1;
>>    becomesTwo = 2;
>>}
>>
>>[...]
>>
>>>I am unable to explain because I haven't the foggiest idea what
>>>you are on about. Explain *what*? 
>>
>>See above and repeat the three steps. Hint: try harder.
> 
> 
> Okay ...
> 
> (G) The specification does not say what to do with the passed values of the
> arguments.
> (H) The specification does not define if setting both values is to be
> atomic; that is, either none is set or both are set, or it doesn't matter.
> (J) The specification does not define what to do when the arguments refer
> to the same memory location.
> 
> Should this routine be a bit more defensive, maybe along the lines of ...
> 
> 
> void letThem( inout int becomesOne, inout int becomesTwo)
> {
>     int localOne;
>     int localTwo;
>     // Ensure the arguments reference two different integer values.
>     if (RAM_Overlaps(&becomesOne, int.sizeof, &becomesTwo, int.sizeof))
>     {
>        throw ReferenceException( ...whatever...);
>     }
> 
>     // Take a local backup of value in case the transaction fails
>     localOne = becomesOne;
>     localTwo = becomesTwo;
> 
>     try {             becomesOne = 1;
>         becomesTwo = 2;
>     }
>     catch(Object e)
>     {
>       // Transaction failed, so restore previous values.
>       becomesOne = localOne;
>       becomesTwo = localTwo;
>       throw e;  // Pass exception up the tree.
>     }
> }
> 

The code isn't thread-safe. Try harder :)
August 07, 2005
On Sun, 07 Aug 2005 18:20:17 +0800, zwang wrote:

> Derek Parnell wrote:
>> On Sun, 7 Aug 2005 08:42:28 +0000 (UTC), Manfred Nowak wrote:
>> 
>> 
>>>Derek Parnell <derek@psych.ward> wrote:
>>>
>>>
>>>>On Sun, 7 Aug 2005 01:05:27 +0000 (UTC), Manfred Nowak wrote:
>>>>
>>>>
>>>>>1) Review this code:
>>>>>
>>>>>void f( inout int i, inout int j){
>>>>>  i= 1;
>>>>>  j= 2;
>>>>>}
>>>>
>>>>Okay, done that.
>>>>
>>>>(A) Function name 'f' is not meaningful enough.
>>>>(B) Argument 'i' is not meaningful enough for the context.
>>>>(C) Argument 'j' is not meaningful enough for the context.
>>>>(D) Inconsistent spacing on lines 2 and 3. Use either
>>>>    <identifer>=<expression>;
>>>>  or
>>>>    <identfier> = <expression>;
>>>>(E) The opening brace should not be on the function declaration
>>>>line. (F) The function body lines are not indented correctly.
>>>>The standard calls for four spaces.
>>>
>>>Okay, you are the quality assurer and I want to implement this routine into a piece of software, that on failure cause severe harm, i.e. loss of lives or money. So I do what you want me to:
>>>
>>>void letThem( inout int becomesOne, inout int becomesTwo)
>>>{
>>>    becomesOne = 1;
>>>    becomesTwo = 2;
>>>}
>>>
>>>[...]
>>>
>>>>I am unable to explain because I haven't the foggiest idea what you are on about. Explain *what*?
>>>
>>>See above and repeat the three steps. Hint: try harder.
>> 
>> 
>> Okay ...
>> 
>> (G) The specification does not say what to do with the passed values of the
>> arguments.
>> (H) The specification does not define if setting both values is to be
>> atomic; that is, either none is set or both are set, or it doesn't matter.
>> (J) The specification does not define what to do when the arguments refer
>> to the same memory location.
>> 
>> Should this routine be a bit more defensive, maybe along the lines of ...
>> 
>> 
>> void letThem( inout int becomesOne, inout int becomesTwo)
>> {
>>     int localOne;
>>     int localTwo;
>>     // Ensure the arguments reference two different integer values.
>>     if (RAM_Overlaps(&becomesOne, int.sizeof, &becomesTwo, int.sizeof))
>>     {
>>        throw ReferenceException( ...whatever...);
>>     }
>> 
>>     // Take a local backup of value in case the transaction fails
>>     localOne = becomesOne;
>>     localTwo = becomesTwo;
>> 
>>     try {
>>         becomesOne = 1;
>>         becomesTwo = 2;
>>     }
>>     catch(Object e)
>>     {
>>       // Transaction failed, so restore previous values.
>>       becomesOne = localOne;
>>       becomesTwo = localTwo;
>>       throw e;  // Pass exception up the tree.
>>     }
>> }
>> 
> 
> The code isn't thread-safe. Try harder :)

Yeah ... As soon as I posted it, it occurred to me too. However, I don't know how to 'do threads' in D yet.

Manfred, is there a point to all of this? Is it possible for you to speak clearly, and in simple terms, about why you suggested this 'joke'?

I'm guessing that you are hinting that D has some really big security holes in it and that is simply a 'bad joke' waiting to laugh at us. But I might be reading in to your minimalistic posting.

-- 
Derek Parnell
Melbourne, Australia
7/08/2005 8:33:15 PM
« First   ‹ Prev
1 2 3 4 5 6 7 8 9