Jump to page: 1 236  
Page
Thread overview
DIP60: @nogc attribute
Apr 15, 2014
Walter Bright
Apr 15, 2014
bearophile
Apr 15, 2014
Walter Bright
Apr 15, 2014
Dicebot
Apr 15, 2014
Walter Bright
Apr 15, 2014
Walter Bright
Apr 15, 2014
John Colvin
Apr 15, 2014
Tove
Apr 15, 2014
Walter Bright
Apr 15, 2014
monarch_dodra
Apr 15, 2014
Walter Bright
Apr 15, 2014
Walter Bright
Apr 15, 2014
Walter Bright
Apr 15, 2014
Walter Bright
Apr 15, 2014
monarch_dodra
Apr 15, 2014
Walter Bright
Apr 15, 2014
Brad Anderson
Apr 15, 2014
Walter Bright
Apr 16, 2014
Meta
Apr 16, 2014
bearophile
Apr 16, 2014
Meta
Apr 16, 2014
w0rp
Apr 15, 2014
Matej Nanut
Apr 16, 2014
Walter Bright
Apr 16, 2014
Adam D. Ruppe
Apr 17, 2014
bearophile
Apr 18, 2014
Jacob Carlborg
Apr 16, 2014
bearophile
Apr 16, 2014
Walter Bright
Apr 16, 2014
Walter Bright
Apr 16, 2014
bearophile
Apr 19, 2014
Marco Leise
Apr 16, 2014
Gary Willoughby
Apr 16, 2014
Gary Willoughby
Apr 15, 2014
H. S. Teoh
Apr 15, 2014
Walter Bright
Apr 15, 2014
monarch_dodra
Apr 15, 2014
Walter Bright
Apr 15, 2014
Walter Bright
Apr 15, 2014
H. S. Teoh
Apr 15, 2014
Tove
Apr 15, 2014
Frustrated
Apr 15, 2014
Walter Bright
Apr 16, 2014
Mike
Apr 16, 2014
Walter Bright
Apr 16, 2014
Mike
Apr 16, 2014
froglegs
Apr 16, 2014
Mike
Apr 20, 2014
Frustrated
Apr 20, 2014
Rikki Cattermole
Apr 20, 2014
Frustrated
Apr 21, 2014
Jacob Carlborg
Apr 21, 2014
Frustrated
Apr 22, 2014
Jacob Carlborg
Apr 16, 2014
JN
Apr 16, 2014
Paulo Pinto
Apr 16, 2014
bearophile
Apr 16, 2014
sclytrack
Apr 17, 2014
Rikki Cattermole
Apr 16, 2014
Manu
Apr 16, 2014
Paulo Pinto
Apr 16, 2014
Walter Bright
Apr 17, 2014
Manu
Apr 17, 2014
Michel Fortin
Apr 17, 2014
Manu
Apr 17, 2014
Walter Bright
Apr 17, 2014
Walter Bright
Apr 17, 2014
Walter Bright
Apr 17, 2014
Walter Bright
Apr 17, 2014
Walter Bright
Apr 17, 2014
Walter Bright
Apr 18, 2014
H. S. Teoh
Apr 18, 2014
Walter Bright
Apr 18, 2014
H. S. Teoh
Apr 18, 2014
Walter Bright
Apr 18, 2014
Manu
Apr 18, 2014
Walter Bright
Apr 18, 2014
John Colvin
Apr 19, 2014
Walter Bright
Apr 21, 2014
Walter Bright
Apr 21, 2014
Walter Bright
Apr 21, 2014
Walter Bright
Apr 22, 2014
Walter Bright
Apr 22, 2014
Kapps
Apr 22, 2014
Michel Fortin
Apr 22, 2014
Kapps
Apr 22, 2014
Jacob Carlborg
Apr 22, 2014
Walter Bright
Apr 22, 2014
John Colvin
Apr 22, 2014
Walter Bright
Apr 22, 2014
Walter Bright
Apr 22, 2014
Walter Bright
Apr 22, 2014
Michel Fortin
Apr 23, 2014
Walter Bright
Apr 23, 2014
Jacob Carlborg
Apr 23, 2014
Michel Fortin
Apr 23, 2014
Michel Fortin
Apr 23, 2014
Manu
Apr 22, 2014
Walter Bright
Apr 23, 2014
Jacob Carlborg
Apr 23, 2014
Jacob Carlborg
Apr 22, 2014
Walter Bright
Apr 23, 2014
Manu
Apr 23, 2014
Walter Bright
Apr 23, 2014
Jacob Carlborg
Apr 23, 2014
Walter Bright
Apr 24, 2014
Jacob Carlborg
Apr 17, 2014
Walter Bright
Apr 18, 2014
Manu
Apr 18, 2014
Walter Bright
Apr 18, 2014
Walter Bright
Apr 18, 2014
Michel Fortin
Apr 18, 2014
Walter Bright
Apr 18, 2014
Adam Wilson
Apr 19, 2014
Michel Fortin
Apr 16, 2014
Adam Wilson
Apr 16, 2014
Walter Bright
Apr 17, 2014
Michel Fortin
Apr 17, 2014
Walter Bright
Apr 17, 2014
Manu
Apr 17, 2014
Manu
Apr 17, 2014
Paulo Pinto
Apr 17, 2014
Paulo Pinto
Apr 17, 2014
Paulo Pinto
Apr 17, 2014
Paulo Pinto
Apr 17, 2014
Walter Bright
Apr 18, 2014
Walter Bright
Apr 18, 2014
Walter Bright
Apr 18, 2014
John Colvin
Apr 18, 2014
Walter Bright
Apr 18, 2014
John Colvin
Apr 18, 2014
Walter Bright
Apr 17, 2014
Manu
Apr 17, 2014
Manu
Apr 18, 2014
Walter Bright
Apr 17, 2014
Manu
Apr 17, 2014
w0rp
Apr 18, 2014
Byron
Apr 18, 2014
Brad Anderson
Apr 18, 2014
Byron
Apr 19, 2014
Jacob Carlborg
Apr 19, 2014
bearophile
Apr 19, 2014
Jacob Carlborg
Apr 19, 2014
Tobias Pankrath
Apr 19, 2014
monarch_dodra
Apr 19, 2014
monarch_dodra
Apr 20, 2014
Jacob Carlborg
Apr 17, 2014
John Colvin
Apr 17, 2014
Manu
Apr 17, 2014
Timon Gehr
Apr 17, 2014
Walter Bright
Apr 18, 2014
Michel Fortin
Apr 18, 2014
Walter Bright
Apr 18, 2014
Walter Bright
Apr 17, 2014
Orvid King
Apr 17, 2014
Regan Heath
Apr 17, 2014
Orvid King
Apr 18, 2014
Jacob Carlborg
Apr 18, 2014
Walter Bright
Apr 18, 2014
bearophile
Apr 19, 2014
Jacob Carlborg
Apr 19, 2014
Walter Bright
Apr 17, 2014
Mike
Apr 17, 2014
Manu
Apr 16, 2014
Walter Bright
Apr 16, 2014
froglegs
Apr 16, 2014
Paulo Pinto
Apr 16, 2014
froglegs
Apr 18, 2014
paulo Pinto
Apr 19, 2014
froglegs
Apr 19, 2014
Paulo Pinto
Apr 16, 2014
Timothee Cour
Apr 16, 2014
justme
Apr 16, 2014
qznc
Apr 16, 2014
Walter Bright
Apr 17, 2014
Regan Heath
Apr 16, 2014
Peter Alexander
Apr 16, 2014
bearophile
Apr 16, 2014
Peter Alexander
Apr 16, 2014
bearophile
Apr 16, 2014
bearophile
Apr 16, 2014
Peter Alexander
Apr 19, 2014
Marco Leise
Apr 20, 2014
monarch_dodra
Apr 21, 2014
Marco Leise
Apr 16, 2014
Timon Gehr
Apr 16, 2014
monarch_dodra
Apr 16, 2014
Walter Bright
Apr 17, 2014
Dejan Lekic
Apr 17, 2014
Rikki Cattermole
Apr 17, 2014
Artur Skawina
Apr 17, 2014
Rikki Cattermole
Apr 17, 2014
Dejan Lekic
Apr 17, 2014
bearophile
Apr 17, 2014
bearophile
Apr 17, 2014
Kapps
Apr 18, 2014
bearophile
Apr 18, 2014
bearophile
Apr 18, 2014
Kapps
Apr 18, 2014
bearophile
Apr 18, 2014
Timon Gehr
Apr 21, 2014
bearophile
Apr 17, 2014
Dicebot
Apr 17, 2014
bearophile
Apr 17, 2014
Dicebot
Apr 17, 2014
Dicebot
Apr 17, 2014
Dicebot
Apr 17, 2014
Dicebot
Apr 17, 2014
monarch_dodra
Apr 17, 2014
Walter Bright
Apr 17, 2014
Walter Bright
Apr 17, 2014
bearophile
Apr 17, 2014
Dicebot
Apr 17, 2014
Walter Bright
Apr 17, 2014
John Colvin
Apr 17, 2014
Walter Bright
Apr 19, 2014
Dicebot
Apr 19, 2014
Walter Bright
Apr 19, 2014
monarch_dodra
Apr 19, 2014
monarch_dodra
Apr 19, 2014
Walter Bright
Apr 19, 2014
Dicebot
Apr 19, 2014
Dicebot
Apr 19, 2014
monarch_dodra
Apr 20, 2014
Manu
Apr 20, 2014
Manu
Apr 19, 2014
Walter Bright
Apr 20, 2014
John Colvin
Apr 21, 2014
Dicebot
Apr 22, 2014
Don
Apr 23, 2014
Walter Bright
Apr 18, 2014
Brad Anderson
Apr 18, 2014
Walter Bright
Apr 18, 2014
Brad Anderson
Apr 18, 2014
Walter Bright
Apr 18, 2014
monarch_dodra
Apr 24, 2014
bearophile
Apr 24, 2014
Walter Bright
Apr 24, 2014
bearophile
Apr 24, 2014
Walter Bright
Apr 25, 2014
bearophile
Apr 25, 2014
David Nadlinger
Apr 25, 2014
Marc Schütz
Apr 27, 2014
Marc Schütz
Apr 25, 2014
Dicebot
Apr 25, 2014
Dicebot
Apr 25, 2014
Dicebot
Apr 26, 2014
Jacob Carlborg
Apr 25, 2014
bearophile
Apr 26, 2014
Walter Bright
Apr 26, 2014
bearophile
Apr 26, 2014
bearophile
Apr 26, 2014
Timon Gehr
Apr 26, 2014
Jacob Carlborg
Apr 26, 2014
Daniel Murphy
Apr 27, 2014
Jacob Carlborg
April 15, 2014
http://wiki.dlang.org/DIP60

Start on implementation:

https://github.com/D-Programming-Language/dmd/pull/3455
April 15, 2014
Walter Bright:

> http://wiki.dlang.org/DIP60

Given the current strong constraints in the directions of D design, I like it.

But in DIPs I suggest to also write a list of the advantages of a proposal, and a list of all the disadvantages.

In this ER I suggested a @noheap, that is meant to also forbid the C memory allocation functions:
https://issues.dlang.org/show_bug.cgi?id=5219
But I guess there is no reliable way to catch those function calls too?
If the discussion is against @noheap then I'll close that ER as obsolete.

With @nogc D has most of the basic function effects covered. One missing effect that D is not yet putting under control is nontermination; to annotate functions that can not loop forever and never return (like a function with an infinite loop inside, etc). But for the kind of programs written in D, I presume this effect is not yet important enough to deserve an annotation like @terminates.

There is a language studied by Microsoft that faces the problem of effects algebra in a more discipled and high-level way. I don't know how much this can help D at its current development stage:
http://research.microsoft.com/en-us/projects/koka/
But in general reading research papers is useful to get in a good mindframe.
In Koka language the functions that can not terminate are annotated with "div", that means "divergence". But Koka has a good effect inference.

Bye,
bearophile
April 15, 2014
On Tue, 15 Apr 2014 13:01:40 -0400, Walter Bright <newshound2@digitalmars.com> wrote:

> http://wiki.dlang.org/DIP60'

Wow, that's quite underspecified.

What about syscalls? Nothrow functions allow one to call non-nothrow functions, but catch all exceptions. What if you want to use the GC for allocation temporarily, and then delete all the usage before returning? Must you use C malloc/free? What about such code that is @safe, which cannot call free?

Off the top of my head...

-Steve
April 15, 2014
On 4/15/2014 11:41 AM, Steven Schveighoffer wrote:
> On Tue, 15 Apr 2014 13:01:40 -0400, Walter Bright <newshound2@digitalmars.com>
> wrote:
>
>> http://wiki.dlang.org/DIP60'
>
> Wow, that's quite underspecified.

Ok, but I don't see how.


> What about syscalls?

Not sure what you mean by that, but obviously Windows API functions would be @nogc.


> Nothrow functions allow one to call non-nothrow functions,
> but catch all exceptions. What if you want to use the GC for allocation
> temporarily, and then delete all the usage before returning?

@nogc doesn't allow an escape from it. That's the point of it.


> Must you use C malloc/free?

If you can GC/GCfree, then you can use malloc/free.


> What about such code that is @safe, which cannot call free?

There's no point to @nogc if you can still call the GC in it.
April 15, 2014
On Tue, 15 Apr 2014 14:58:25 -0400, Walter Bright <newshound2@digitalmars.com> wrote:

> On 4/15/2014 11:41 AM, Steven Schveighoffer wrote:
>> On Tue, 15 Apr 2014 13:01:40 -0400, Walter Bright <newshound2@digitalmars.com>
>> wrote:
>>
>>> http://wiki.dlang.org/DIP60'
>>
>> Wow, that's quite underspecified.
>
> Ok, but I don't see how.

i.e. the rest of my post.

>> What about syscalls?
>
> Not sure what you mean by that, but obviously Windows API functions would be @nogc.

Linux syscalls are not Windows API, they are extern(C) calls. Basically, we will have to mark most as @nogc, right? or are extern(C) calls automatically considered @nogc?

>> Nothrow functions allow one to call non-nothrow functions,
>> but catch all exceptions. What if you want to use the GC for allocation
>> temporarily, and then delete all the usage before returning?
>
> @nogc doesn't allow an escape from it. That's the point of it.

My point:

void foo1() {throw new Exception("hi");}

void foo2() nothrow { try {foo1();} catch(Exception e) {} }

This is valid.

int isthisok(int x, int y) @nogc
{
   // need scratch space
   int[] buf = new int[x * y];
   scope(exit) GC.free(buf.ptr);
   // perform some algorithm using buf
   ...
   //
   return buf[$-1];
}

Valid?

>> Must you use C malloc/free?
>
> If you can GC/GCfree, then you can use malloc/free.

What if you can't use GC/GCfree? i.e. @nogc (the point of this thread)

>> What about such code that is @safe, which cannot call free?
>
> There's no point to @nogc if you can still call the GC in it.

This is a follow-on to the previous question. Let's say you cannot use GC, but clearly, I can use C malloc/free. Safe code that needs arbitrary buffers must use C malloc/free to manage them, but safe cannot legally call free.

I think we would need some sort of scoped allocator to make life bearable.

-Steve
April 15, 2014
On Tue, 15 Apr 2014 14:41:36 -0400, Steven Schveighoffer <schveiguy@yahoo.com> wrote:

> On Tue, 15 Apr 2014 13:01:40 -0400, Walter Bright <newshound2@digitalmars.com> wrote:
>
>> http://wiki.dlang.org/DIP60'
>
> Wow, that's quite underspecified.

What specifically is prevented? GC.malloc, GC.free, clearly. What about GC.getAttr? GC.query? These will not invoke collection cycles (the point of @nogc).

Actually, maybe just fullcollect is the root @nogc method...

In any case, more concrete details should be specified in the DIP.

-Steve
April 15, 2014
On Tue, 15 Apr 2014 15:14:47 -0400, Steven Schveighoffer <schveiguy@yahoo.com> wrote:

> Actually, maybe just fullcollect is the root @nogc method...

Said that wrong, fullcollect is the base method you cannot mark as @nogc.

-Steve
April 15, 2014
On Tuesday, 15 April 2014 at 19:12:30 UTC, Steven Schveighoffer wrote:
> int isthisok(int x, int y) @nogc
> {
>    // need scratch space
>    int[] buf = new int[x * y];
>    scope(exit) GC.free(buf.ptr);
>    // perform some algorithm using buf
>    ...
>    //
>    return buf[$-1];
> }
>
> Valid?

No way. This can trigger GC collection. @nogc is not about observable pre- and post- state but about prohibiting specific operation completely.
April 15, 2014
On 4/15/2014 12:12 PM, Steven Schveighoffer wrote:
>>> What about syscalls?
>>
>> Not sure what you mean by that, but obviously Windows API functions would be
>> @nogc.
>
> Linux syscalls are not Windows API, they are extern(C) calls. Basically, we will
> have to mark most as @nogc, right?

Right, just like nothrow.


> or are extern(C) calls automatically considered @nogc?

No, just like for nothrow.


> int isthisok(int x, int y) @nogc
> {
>     // need scratch space
>     int[] buf = new int[x * y];
>     scope(exit) GC.free(buf.ptr);
>     // perform some algorithm using buf
>     ...
>     //
>     return buf[$-1];
> }
>
> Valid?

No.


>>> Must you use C malloc/free?
>>
>> If you can GC/GCfree, then you can use malloc/free.
>
> What if you can't use GC/GCfree? i.e. @nogc (the point of this thread)

Then use malloc/free.


>>> What about such code that is @safe, which cannot call free?
>>
>> There's no point to @nogc if you can still call the GC in it.
>
> This is a follow-on to the previous question. Let's say you cannot use GC, but
> clearly, I can use C malloc/free. Safe code that needs arbitrary buffers must
> use C malloc/free to manage them, but safe cannot legally call free.

That's why @trusted exists.


> I think we would need some sort of scoped allocator to make life bearable.

    p = malloc(...);
    scope(exit) free(p);

Let's be clear about the motivation for @nogc - there are a lot of people who will not use D because of fear of GC. They want a guarantee that the GC isn't being called. They don't want code that hides calls to GC.
April 15, 2014
On 4/15/2014 12:14 PM, Steven Schveighoffer wrote:
> On Tue, 15 Apr 2014 14:41:36 -0400, Steven Schveighoffer <schveiguy@yahoo.com>
> wrote:
>
>> On Tue, 15 Apr 2014 13:01:40 -0400, Walter Bright <newshound2@digitalmars.com>
>> wrote:
>>
>>> http://wiki.dlang.org/DIP60'
>>
>> Wow, that's quite underspecified.
>
> What specifically is prevented?

All calls to the GC.

« First   ‹ Prev
1 2 3 4 5 6 7 8 9 10 11