| Thread overview | |||||
|---|---|---|---|---|---|
|
February 24, 2004 [Language design] trapped into an error due to opCall | ||||
|---|---|---|---|---|
| ||||
I am playing with the implementation of a hashing function `f'.
The hashing function is implemented in a class using `opCall'. One definition looks like `void opCall( void* ptr)'. This definition was tested and worked.
Further testing and extending the class showed, that I had to use a
function `foo' that was used like
`someVariable= foo(someVariable);'.
Instead of making `someVariable' public, I decided to include one further
definition of `opCall':
void opCall( int delegate(int) bar){
someVariable= bar(someVariable);
}
and used it like `f(&foo)'.
I got wrong results. Reactivating the printouts of the `opCall' first mentioned showed that it got wrong data: `224 0 0 0' instead of `0 0 0 0'.
If you already see, what error I made, then you need not unrot13 the following nor even look at it:
`sbb' jnf abg n shapgvba, nyfb vg ybbxrq nyvxr. Vg jnf n pynff gung hfrq
`bcPnyy' vgfrys. Fb gur pbeerpg pnyy unq gb or `s(&sbb.bcPnyy)' vafgrnq bs
`s(&sbb)'.
Should the language take precautions to prevent such errors?
So long.
| ||||
February 24, 2004 Re: [Language design] trapped into an error due to opCall | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Manfred Nowak | <snip> In article <c1e4fq$hn4$1@digitaldaemon.com>, Manfred Nowak says... >Should the language take precautions to prevent such errors? </snip> As long as what's written is valid the language shouldn't prevent the user (or is that misuser?) from making errors. We're all free to make whatever errors we like. | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply