Jump to page: 1 2
Thread overview
DConf Day 1 Panel with Walter Bright and Andrei Alexandrescu
Jun 27, 2014
Dicebot
Jun 27, 2014
Walter Bright
Jul 02, 2014
Brian Rogoff
Jun 27, 2014
safety0ff
Jun 28, 2014
Peter Alexander
Jun 28, 2014
safety0ff
Jun 28, 2014
Peter Alexander
Jun 28, 2014
safety0ff
Jun 28, 2014
Sönke Ludwig
Jun 28, 2014
safety0ff
Jun 29, 2014
Meta
Jun 29, 2014
Meta
June 27, 2014
http://www.reddit.com/r/programming/comments/298vtt/dconf_2014_panel_with_walter_bright_and_andrei/

https://twitter.com/D_Programming/status/482546357690187776

https://news.ycombinator.com/newest

https://www.facebook.com/dlang.org/posts/874091959271153


Andrei
June 27, 2014
http://youtu.be/TNvUIWFy02I
June 27, 2014
On 6/27/2014 12:53 PM, Dicebot wrote:
> http://youtu.be/TNvUIWFy02I

Ack, need to work on my posture :-(
June 27, 2014
I have two questions that I've come upon lately:

1) How was it decided that there should be implicit conversion between signed and unsigned integers in arithmetic operations, and why prefer unsigned numbers?
E.g. Signed / Unsigned = Unsigned
Is this simply compatibility with C or is there something greater behind this decision.

2) With regard to reducing template instantiations:
I've been using a technique similar to the one mentioned in the video: separating functions out of templates to reduce bloat.
My question is: does a template such as:
T foo(T)(T x)
if (isIntegral!T) { return x; }

Get instantiated multiple times for const, immutable, etc. qualifiers on the input?
June 28, 2014
On Friday, 27 June 2014 at 23:30:39 UTC, safety0ff wrote:
> 2) With regard to reducing template instantiations:
> I've been using a technique similar to the one mentioned in the video: separating functions out of templates to reduce bloat.
> My question is: does a template such as:
> T foo(T)(T x)
> if (isIntegral!T) { return x; }
>
> Get instantiated multiple times for const, immutable, etc. qualifiers on the input?

Yes, but bear in mind that those qualifiers are often stripped
with IFTI, e.g.:

int a;
const int b;
immutable int c;
foo(a);
foo(b);
foo(c);

These all call foo!int
June 28, 2014
On Saturday, 28 June 2014 at 02:02:28 UTC, Peter Alexander wrote:
> On Friday, 27 June 2014 at 23:30:39 UTC, safety0ff wrote:
>> 2) With regard to reducing template instantiations:
>> I've been using a technique similar to the one mentioned in the video: separating functions out of templates to reduce bloat.
>> My question is: does a template such as:
>> T foo(T)(T x)
>> if (isIntegral!T) { return x; }
>>
>> Get instantiated multiple times for const, immutable, etc. qualifiers on the input?
>
> Yes, but bear in mind that those qualifiers are often stripped
> with IFTI, e.g.:
>
> int a;
> const int b;
> immutable int c;
> foo(a);
> foo(b);
> foo(c);
>
> These all call foo!int

Awesome, thanks!
June 28, 2014
On Saturday, 28 June 2014 at 02:46:25 UTC, safety0ff wrote:
> On Saturday, 28 June 2014 at 02:02:28 UTC, Peter Alexander
>> int a;
>> const int b;
>> immutable int c;
>> foo(a);
>> foo(b);
>> foo(c);
>>
>> These all call foo!int
>
> Awesome, thanks!

... I just tried this and I'm wrong. The qualifier isn't stripped. Gah! Three different versions!

I could have sworn D did this for primitive types. This makes me sad :-(
June 28, 2014
On Saturday, 28 June 2014 at 03:33:37 UTC, Peter Alexander wrote:
>
> ... I just tried this and I'm wrong. The qualifier isn't stripped. Gah! Three different versions!
>
> I could have sworn D did this for primitive types. This makes me sad :-(

I guess you can make all kinds of code that depends on the qualifier.

I tried using ld.gold to play with icf (identical code folding,) but I did not manage to get a working binary out of gold (regardless of icf.)
June 28, 2014
Am 28.06.2014 05:33, schrieb Peter Alexander:
> On Saturday, 28 June 2014 at 02:46:25 UTC, safety0ff wrote:
>> On Saturday, 28 June 2014 at 02:02:28 UTC, Peter Alexander
>>> int a;
>>> const int b;
>>> immutable int c;
>>> foo(a);
>>> foo(b);
>>> foo(c);
>>>
>>> These all call foo!int
>>
>> Awesome, thanks!
>
> ... I just tried this and I'm wrong. The qualifier isn't stripped. Gah!
> Three different versions!
>
> I could have sworn D did this for primitive types. This makes me sad :-(

I *think* it does this if you define foo as "foo(T)(const(T) arg)", though.
June 28, 2014
On Saturday, 28 June 2014 at 16:51:56 UTC, Sönke Ludwig wrote:
> Am 28.06.2014 05:33, schrieb Peter Alexander:
>> On Saturday, 28 June 2014 at 02:46:25 UTC, safety0ff wrote:
>>> On Saturday, 28 June 2014 at 02:02:28 UTC, Peter Alexander
>>>> int a;
>>>> const int b;
>>>> immutable int c;
>>>> foo(a);
>>>> foo(b);
>>>> foo(c);
>>>>
>>>> These all call foo!int
>>>
>>> Awesome, thanks!
>>
>> ... I just tried this and I'm wrong. The qualifier isn't stripped. Gah!
>> Three different versions!
>>
>> I could have sworn D did this for primitive types. This makes me sad :-(
>
> I *think* it does this if you define foo as "foo(T)(const(T) arg)", though.

Thanks, that works.
std.math doesn't do this for its templated functions, should it?

Is there an easy way to shared-strip primitive types?
Perhaps passing non-ref/non-pointer primitive data to const(T) should implicitly strip shared.
Reading of the shared data occurs at the call site.
Are there any use cases where passing on the shared-ness of a primitive type to non-ref const(T) is useful?
« First   ‹ Prev
1 2