Jump to page: 1 2
Thread overview
Boston D Meetup: Strawman Structs
Jul 22, 2017
Nicholas Wilson
Jul 23, 2017
Nicholas Wilson
Jul 23, 2017
Moritz Maxeiner
Jul 25, 2017
John Colvin
Jul 25, 2017
Nicholas Wilson
July 02, 2017
I'll have a short presentation on a weird trick I discovered while writing some MySQL serialization code. Hope you can attend!

https://www.eventbrite.com/e/d-lang-presentation-strawman-structs-tickets-35120523431

-Steve
July 02, 2017
On 7/2/17 6:35 AM, Steven Schveighoffer wrote:
> I'll have a short presentation on a weird trick I discovered while writing some MySQL serialization code. Hope you can attend!
> 
> https://www.eventbrite.com/e/d-lang-presentation-strawman-structs-tickets-35120523431 

I've moved this to Friday to accommodate more people.

-Steve
July 21, 2017
On 7/2/17 6:35 AM, Steven Schveighoffer wrote:
> I'll have a short presentation on a weird trick I discovered while writing some MySQL serialization code. Hope you can attend!
> 
> https://www.eventbrite.com/e/d-lang-presentation-strawman-structs-tickets-35120523431 

I've set up a live stream for this. No guarantees of the quality, it will be audio + slideshow.

Waiting for people to arrive, so probably won't start until at least 6:30.

https://www.youtube.com/watch?v=ZxzczSDaobw

-Steve
July 22, 2017
On Friday, 21 July 2017 at 21:55:01 UTC, Steven Schveighoffer wrote:
> On 7/2/17 6:35 AM, Steven Schveighoffer wrote:
>> I'll have a short presentation on a weird trick I discovered while writing some MySQL serialization code. Hope you can attend!
>> 
>> https://www.eventbrite.com/e/d-lang-presentation-strawman-structs-tickets-35120523431
>
> I've set up a live stream for this. No guarantees of the quality, it will be audio + slideshow.
>
> Waiting for people to arrive, so probably won't start until at least 6:30.
>
> https://www.youtube.com/watch?v=ZxzczSDaobw
>
> -Steve

Great talk! It seems great mids think alike, I will be using this to implement OpenCL's horrible getInfo.
https://github.com/libmir/dcompute/blob/master/source/dcompute/driver/ocl120/util.d#L36
https://github.com/libmir/dcompute/blob/master/source/dcompute/driver/ocl120/device.d#L67

Regarding the inferred attribute problem with the concepts like Straw-man usage, this should not be a problem with my attributes DIP, since all special attributes become normal attributes and you could just have an AliasSeq of the required values.

July 22, 2017
On 7/21/17 8:49 PM, Nicholas Wilson wrote:
> On Friday, 21 July 2017 at 21:55:01 UTC, Steven Schveighoffer wrote:
>> On 7/2/17 6:35 AM, Steven Schveighoffer wrote:
>>> I'll have a short presentation on a weird trick I discovered while writing some MySQL serialization code. Hope you can attend!
>>>
>>> https://www.eventbrite.com/e/d-lang-presentation-strawman-structs-tickets-35120523431 
>>>
>>
>> I've set up a live stream for this. No guarantees of the quality, it will be audio + slideshow.
>>
>> Waiting for people to arrive, so probably won't start until at least 6:30.
>>
>> https://www.youtube.com/watch?v=ZxzczSDaobw
>>
> 
> Great talk! 

Thanks!

> 
> Regarding the inferred attribute problem with the concepts like Straw-man usage, this should not be a problem with my attributes DIP, since all special attributes become normal attributes and you could just have an AliasSeq of the required values.

Maybe I'm misunderstanding you, but my concern is that something like this:

struct StrawmanRange(T)
{
  ...
  void popFront() {}
}

So popFront would be inferred to be pure, @safe, and nothrow. However, since really we want to only do what was specified, we don't want the compiler inferring this. More specifically, I wouldn't want the `implements` function generating requirements that a suitable range struct must have @safe nothrow pure popFront. I don't think introspection can tell whether the attributes were specified or inferred.

I don't see how being able to combine attributes is going to be able to prevent compiler inference of them. Or maybe I am missing something?

-Steve

July 23, 2017
On Sunday, 23 July 2017 at 02:15:18 UTC, Steven Schveighoffer wrote:
> On 7/21/17 8:49 PM, Nicholas Wilson wrote:
>> On Friday, 21 July 2017 at 21:55:01 UTC, Steven Schveighoffer wrote:
>>> On 7/2/17 6:35 AM, Steven Schveighoffer wrote:
>>>> I'll have a short presentation on a weird trick I discovered while writing some MySQL serialization code. Hope you can attend!
>>>>
>>>> https://www.eventbrite.com/e/d-lang-presentation-strawman-structs-tickets-35120523431
>>>>
>>>
>>> I've set up a live stream for this. No guarantees of the quality, it will be audio + slideshow.
>>>
>>> Waiting for people to arrive, so probably won't start until at least 6:30.
>>>
>>> https://www.youtube.com/watch?v=ZxzczSDaobw
>>>
>> 
>> Great talk!
>
> Thanks!
>
>> 
>> Regarding the inferred attribute problem with the concepts like Straw-man usage, this should not be a problem with my attributes DIP, since all special attributes become normal attributes and you could just have an AliasSeq of the required values.
>
> Maybe I'm misunderstanding you, but my concern is that something like this:
>
> struct StrawmanRange(T)
> {
>   ...
>   void popFront() {}
> }
>
> So popFront would be inferred to be pure, @safe, and nothrow. However, since really we want to only do what was specified, we don't want the compiler inferring this. More specifically, I wouldn't want the `implements` function generating requirements that a suitable range struct must have @safe nothrow pure popFront. I don't think introspection can tell whether the attributes were specified or inferred.
>
> I don't see how being able to combine attributes is going to be able to prevent compiler inference of them. Or maybe I am missing something?
>
> -Steve

Its the combining with AliasSeq in conjunction with being normal (albeit compiler recognised) attributes that makes it work. It doesn't matter what the compiler infers because the struct knows, with RequiredAttributes, what attributes are _actually_ required E.g.

struct RequiredAttributes(Values...) if(AllSatisfy!(isCoreAttributeValue, Values))
{
    alias values = AliasSeq!(Values);
}

 struct StrawmanRange(T)
 {
    @RequiredAttributes!(): // i.e. no attributes required
    // or use
    //@RequiredAttributes!(safe,nothrow,nogc,pure): for very strict functions
    // can apply this on a per symbol basis too.

    @property T front();
    bool empty();
    void popFront() {}
 }

and reflect on the RequiredAttributes.values to force the "correct" attributes in `implements` and `describeDifferences`.

// roughly and ignoring optional methods
bool Implements(Strawman,T)()
{
    foreach(m; __traits(allMembers, Strawman)
    {
        static if (!hasMember!(T,m)
            return false;
        else static if (!isCovariantWith!(__traits(getMember, T, m),getUDA!(__traits(getMember, Strawman, m), RequiredAttributes). values)
            return false;
    }
    return true;
}

July 23, 2017
On Sunday, 23 July 2017 at 02:15:18 UTC, Steven Schveighoffer wrote:
>
> struct StrawmanRange(T)
> {
>   ...
>   void popFront() {}
> }

How do you deal with ranges where `.popFront` returns the old front element (`.front` requires copying the front element if the caller wants to store it, `.popFront` can move it)?
July 24, 2017
On 7/23/17 9:50 AM, Moritz Maxeiner wrote:
> On Sunday, 23 July 2017 at 02:15:18 UTC, Steven Schveighoffer wrote:
>>
>> struct StrawmanRange(T)
>> {
>>   ...
>>   void popFront() {}
>> }
> 
> How do you deal with ranges where `.popFront` returns the old front element (`.front` requires copying the front element if the caller wants to store it, `.popFront` can move it)?

As I said in the talk, there's not an actual library for this, it's just an idea. I would say you could probably return Any here, and infer that means the return type doesn't matter. Or you could have an attribute. The idea is to communicate in some way to the "implements" function how to create the right constraint.

-Steve
July 24, 2017
On 07/21/2017 05:55 PM, Steven Schveighoffer wrote:
> On 7/2/17 6:35 AM, Steven Schveighoffer wrote:
>> I'll have a short presentation on a weird trick I discovered while writing some MySQL serialization code. Hope you can attend!
> 
> https://www.youtube.com/watch?v=ZxzczSDaobw
> 

Very cool.
July 25, 2017
On Sunday, 2 July 2017 at 10:35:49 UTC, Steven Schveighoffer wrote:
> I'll have a short presentation on a weird trick I discovered while writing some MySQL serialization code. Hope you can attend!
>
> https://www.eventbrite.com/e/d-lang-presentation-strawman-structs-tickets-35120523431
>
> -Steve

Is there a written summary of the idea? Or is there a specific point in the video someone could point me to?
« First   ‹ Prev
1 2