March 07, 2006
In article <dui6d5$2134$1@digitaldaemon.com>, Johan Granberg says...
>
>Hasan Aljudy wrote:
>>> Because then i would have to call a method to read bar and that would bee inefective.
>> 
>> You know, CPUs are fast now a days, a single function call is not "ineffective".
>
>That argument does not hold if you are in a tight loop it will matter.

A one-line return method is going to get inlined by the compiler, so it is unlikely you will see any performance difference at all.


March 07, 2006
"Johan Granberg" <lijat.meREM@OVEgmail.com> wrote in message news:duhntk$1a51$1@digitaldaemon.com...
> I remembered another thing that i would like as well. This probably is omited by design but I would realy like to write member funktion definitions outside of their class. This way i can get the class definition down to a single page and that helps when trying to read the code later on as you can easily see the properities of a class at a glance.

You can do that now by creating a separate ".di" file which does not contain the function bodies. See the -H switch.


March 07, 2006
Walter Bright wrote:
> "Johan Granberg" <lijat.meREM@OVEgmail.com> wrote in message news:duhntk$1a51$1@digitaldaemon.com...
>> I remembered another thing that i would like as well. This probably is omited by design but I would realy like to write member funktion definitions outside of their class. This way i can get the class definition down to a single page and that helps when trying to read the code later on as you can easily see the properities of a class at a glance.
> 
> You can do that now by creating a separate ".di" file which does not contain the function bodies. See the -H switch. 
> 
> 
I knew of the -H switch but had not thought about using the di files that way. thanks :)
March 08, 2006
Johan Granberg wrote:

>> 3. read only sematics that work as a strong reminder that one is
>> not suposed to modify somthing (but can be subverted by a cast) 

(Just a thought:)

I wonder if everybody here is thinking like this:

void foo(const int arg)
{
    // whatever
}

void main()
{
    int bar = 3;
    foo(bar);
}

Now, suppose we change the whole thing into:

void foo(int arg)
{
    // whatever
}

void main()
{
    int bar = 3;
    foo(const bar);
}

---

Comments? Ideas?

In non-release code the calling code could inclucde implicit tests for variable "sameness", i.e. check that the value is unchanged over the function call. That way the callee could simply be unaffected by this new twist. Right?

After all, it's the calling code that's interested in "constness", not the callee. Or have I missed something?
March 08, 2006
In article <440E2E4C.6090902@nospam.org>, Georg Wrede says...
>
>Johan Granberg wrote:
>
>>> 3. read only sematics that work as a strong reminder that one is not suposed to modify somthing (but can be subverted by a cast)
>
>(Just a thought:)
>
>I wonder if everybody here is thinking like this:
>
>void foo(const int arg)
>{
>     // whatever
>}
>
>void main()
>{
>     int bar = 3;
>     foo(bar);
>}
>
>Now, suppose we change the whole thing into:
>
>void foo(int arg)
>{
>     // whatever
>}
>
>void main()
>{
>     int bar = 3;
>     foo(const bar);
>}
>
>---
>
>Comments? Ideas?
>
>In non-release code the calling code could inclucde implicit tests for variable "sameness", i.e. check that the value is unchanged over the function call. That way the callee could simply be unaffected by this new twist. Right?
>
>After all, it's the calling code that's interested in "constness", not the callee. Or have I missed something?

Other people have proposed this... its probably possible but would be costly.

You could do this and get nearly the same effect:

foo(bar.dup);

Of course, it would not work for int, but you don't need it for those.  It would also not be "deep" constness, which would be hard to do in your method also.

I think the "deep" equality and "deep" const, and recursiveness of const (i.e. const to sub-functions and sub-objects) is most of what makes it hard to implement.

I've often found that const "catches" me in C++, but what it saves me from is usually just "lack of const correctness".  I'm not sure how often it has actually saved me from writing bad code.  In any case, Walter doesn't see a big enough benefit from it.

I have an idea on const that I'll sketch up and post in a sec.

Kevin


March 08, 2006
Walter Bright wrote:
> 
> What does D have to do to have more power than C++? 
> 
> 

Real DLL support!
3 4 5 6 7 8 9 10 11 12 13
Next ›   Last »