Re: DIP 1003: remove `body` as a keyword

2016-11-21 Thread Piotrek via Digitalmars-d-announce

On Monday, 21 November 2016 at 20:59:32 UTC, Timon Gehr wrote:
How about this alternative ("in" and "out" blocks inside 
function body):


void foo(int a)
{
in
{
assert (a > 0);
}
out
{
(ret) assert(ret > 0);
}

// body code

return a;
}


or for one-liners:

void foo(int a)
{
in assert (a > 0);
out (ret) assert(ret > 0);

// body code

return a;
}

BR,
Piotrek


Won't work. Contracts are part of the function signature. 
That's the point.


How does "auto" work? Can't the inner in be applied to the 
signature?


BR,
Piotrek


Re: DIP 1003: remove `body` as a keyword

2016-11-21 Thread Timon Gehr via Digitalmars-d-announce

On 19.11.2016 22:16, Dicebot wrote:

DIP 1003 is merged to the queue and open for public informal feedback.

PR: https://github.com/dlang/DIPs/pull/48
Initial merged document:
https://github.com/dlang/DIPs/blob/master/DIPs/DIP1003.md

If you want the change to be approved and have ideas how to improve it
to better match on
https://github.com/dlang/DIPs/blob/master/GUIDELINES.md and existing
published reviews - please submit new PR with editorial and ping
original author.


I'm opposed to both option 2 and option 3 on the basis that they are 
both plain ugly (also, breaking), 2 is verbose, 3 is ambiguous. (Doing 
nothing is much better than 2 or 3.)


For option 1, the "on the basis that they will complicate the parser" 
argument is weak. Just lex 'body' as an identifier and expect to see 
that identifier in the parser. TOKbody occurs 4 times in DMD's parser, 
all of them are trivial to replace.


Re: DIP 1003: remove `body` as a keyword

2016-11-21 Thread Timon Gehr via Digitalmars-d-announce

On 21.11.2016 17:55, Piotrek wrote:

On Saturday, 19 November 2016 at 21:16:15 UTC, Dicebot wrote:

DIP 1003 is merged to the queue and open for public informal feedback.

PR: https://github.com/dlang/DIPs/pull/48
Initial merged document:
https://github.com/dlang/DIPs/blob/master/DIPs/DIP1003.md

If you want the change to be approved and have ideas how to improve it
to better match on
https://github.com/dlang/DIPs/blob/master/GUIDELINES.md and existing
published reviews - please submit new PR with editorial and ping
original author.


How about this alternative ("in" and "out" blocks inside function body):

void foo(int a)
{
in
{
assert (a > 0);
}
out
{
(ret) assert(ret > 0);
}

// body code

return a;
}


or for one-liners:

void foo(int a)
{
in assert (a > 0);
out (ret) assert(ret > 0);

// body code

return a;
}

BR,
Piotrek


Won't work. Contracts are part of the function signature. That's the point.


Re: Nov 16 - Memory Safety and the D Programming Language

2016-11-21 Thread Walter Bright via Digitalmars-d-announce

On 11/21/2016 7:20 AM, ixid wrote:

On Sunday, 20 November 2016 at 22:34:26 UTC, Walter Bright wrote:

On 11/14/2016 1:39 AM, qznc wrote:

On Monday, 14 November 2016 at 06:57:07 UTC, Walter Bright wrote:

· Follow our YouTube channel.


So, there will be a recording? Great!



Unfortunately, the audio was lost 18 minutes in. Looks to be not worth
posting. I do have the slides up, though.

http://www.walterbright.com


Would it be worth the D Foundation investing in a good portable setup for
recording people's talks? Certainly for the main D conference but also for the
core team members and other VIPs. There is considerable value in high quality
recordings being available. The quality of some previously has been very poor
due to the limitations of the equipment available.

Also some shared guidance about how to record a talk effectively.


I was wearing a wireless Lavalier microphone. I suspect what happened is the 
batteries in it died. The mike is professional (it's Microsoft's) but that 
doesn't help if one doesn't remember to install fresh batteries.


Re: Nov 16 - Memory Safety and the D Programming Language

2016-11-21 Thread Wyatt via Digitalmars-d-announce

On Monday, 21 November 2016 at 16:01:27 UTC, Antonio Corbi wrote:
Maybe some ideas could be taken from here: 
https://wiki.debconf.org/wiki/Videoteam


The only thing they don't seem to do that I'd additionally 
recommend is take another separate audio recording using a 
separate voice recorder.


I have an old Alesis pocket recorder that works well for these 
things (used it for recording lectures back in school), but I'm 
sure there are dozens out there.  They tend to have pretty good 
mics in them, so they might just work from your pocket, but you 
should be able to plug in a clip mic too.


-Wyatt


Dlang dynamic compilation

2016-11-21 Thread Ivan Butygin via Digitalmars-d-announce

Hi all
Here is my small project - ability to move some code optimization 
and generation to runtime.
Any function can be marked with special attribute and llvm 
bitcode for it will saved in binary.
Then during runtime it will be optimized and compiled (and it can 
use best available cpu instructions).


@runtimeCompile void bar()
{
...
}

...

// Somewhere in main
rtCompileProcess(settings); // Compile
bar();

Another feature - ability to create "runtime compiletime 
variables" - you can set them during runtime and then they will 
be treated as constants during optimization and codegeneration.


@runtimeCompile __gshared int var;
@runtimeCompile void bar()
{
// var is treated as constant in generated code and subject 
to constant propagation, loop unrolling, etc

foreach(int i; 0..var)
{
}

if(var == 42) // This block will be removed comletely if var 
is not 42

{
}
}

// Somewhere in main
var = 42;
rtCompileProcess(settings); // Compile
bar();

var = 13; // To see changed value in runtime compiled code 
recompilation is required

rtCompileProcess(settings); // Compile
bar();

This is an early prototype and mostly untested but simple 
examples work.


Hacked ldc sources are here:
https://github.com/Hardcode84/ldc/tree/runtime_compile



Re: DIP 1003: remove `body` as a keyword

2016-11-21 Thread Piotrek via Digitalmars-d-announce

On Saturday, 19 November 2016 at 21:16:15 UTC, Dicebot wrote:
DIP 1003 is merged to the queue and open for public informal 
feedback.


PR: https://github.com/dlang/DIPs/pull/48
Initial merged document: 
https://github.com/dlang/DIPs/blob/master/DIPs/DIP1003.md


If you want the change to be approved and have ideas how to 
improve it to better match on 
https://github.com/dlang/DIPs/blob/master/GUIDELINES.md and 
existing published reviews - please submit new PR with 
editorial and ping original author.


How about this alternative ("in" and "out" blocks inside function 
body):


void foo(int a)
{
in
{
assert (a > 0);
}
out
{
(ret) assert(ret > 0);
}

// body code

return a;
}


or for one-liners:

void foo(int a)
{
in assert (a > 0);
out (ret) assert(ret > 0);

// body code

return a;
}

BR,
Piotrek


Re: Nov 16 - Memory Safety and the D Programming Language

2016-11-21 Thread Antonio Corbi via Digitalmars-d-announce

On Monday, 21 November 2016 at 15:20:49 UTC, ixid wrote:
On Sunday, 20 November 2016 at 22:34:26 UTC, Walter Bright 
wrote:

On 11/14/2016 1:39 AM, qznc wrote:

[...]



Unfortunately, the audio was lost 18 minutes in. Looks to be 
not worth posting. I do have the slides up, though.


http://www.walterbright.com


Would it be worth the D Foundation investing in a good portable 
setup for recording people's talks? Certainly for the main D 
conference but also for the core team members and other VIPs. 
There is considerable value in high quality recordings being 
available. The quality of some previously has been very poor 
due to the limitations of the equipment available.


Also some shared guidance about how to record a talk 
effectively.


Maybe some ideas could be taken from here: 
https://wiki.debconf.org/wiki/Videoteam


Antonio


Re: Nov 16 - Memory Safety and the D Programming Language

2016-11-21 Thread ixid via Digitalmars-d-announce

On Sunday, 20 November 2016 at 22:34:26 UTC, Walter Bright wrote:

On 11/14/2016 1:39 AM, qznc wrote:
On Monday, 14 November 2016 at 06:57:07 UTC, Walter Bright 
wrote:

· Follow our YouTube channel.


So, there will be a recording? Great!



Unfortunately, the audio was lost 18 minutes in. Looks to be 
not worth posting. I do have the slides up, though.


http://www.walterbright.com


Would it be worth the D Foundation investing in a good portable 
setup for recording people's talks? Certainly for the main D 
conference but also for the core team members and other VIPs. 
There is considerable value in high quality recordings being 
available. The quality of some previously has been very poor due 
to the limitations of the equipment available.


Also some shared guidance about how to record a talk effectively.


Re: DIP 1003: remove `body` as a keyword

2016-11-21 Thread Sönke Ludwig via Digitalmars-d-announce

Am 19.11.2016 um 22:16 schrieb Dicebot:

DIP 1003 is merged to the queue and open for public informal feedback.

PR: https://github.com/dlang/DIPs/pull/48
Initial merged document:
https://github.com/dlang/DIPs/blob/master/DIPs/DIP1003.md

If you want the change to be approved and have ideas how to improve it
to better match on
https://github.com/dlang/DIPs/blob/master/GUIDELINES.md and existing
published reviews - please submit new PR with editorial and ping
original author.


I'd really like to see option 3, combined with option 1. The verbosity 
of the current syntax, as well as the sub-optimal contract semantics for 
classes*, make me personally almost always resort to normal assertions 
in the function body instead of using contracts.


That "body" is not available as an identifier is also quite annoying for 
certain applications. This is the case for a bunch of other keywords, 
too, but "body" as a keyword just has extremely little value, so it does 
stick out.


Really nice would be if "in" and "out" would then also take a general 
statement instead of just a block statement, so that a syntax like this 
would become possible for simple contracts:


void foo(int a, int b)
  in assert(0 <= a && a < b);
  out(ret) assert(ret < b);
{
  return b - 1 - a;
}

The current equivalent just looks crowded and becomes hard to read, or 
wastes lots of vertical space if braces are put on their own line:


void foo(int a, int b)
  in { assert(0 <= a && a < b); }
  out(ret) { assert(ret < b); }
body {
  return b - 1 - a;
}

For this whole proposal to work out, though, I think the old syntax will 
have to stay supported without deprecations, because the amount of 
breakage (the deprecation path won't change that) will otherwise 
probably be huge. Making "body" optional + contextual seems to be the 
way to go.


Since "body" is only used in a tiny and specific grammatical niche of 
the language, I also think that Walter's generic arguments form the 
linked thread don't really apply here, similar to "scope(...)" or 
"extern(...)".





* Example:

interface Foo {
  void foo(int x) in { assert(x < 10); };
}

class Bar : Foo {
  // no contract enforced, because an omitted contract always
  // counts as a passing contract - need in { assert(false); } here
  override void foo(int x) { ... }
}



Re: DIP 1003: remove `body` as a keyword

2016-11-21 Thread Dejan Lekic via Digitalmars-d-announce

On Saturday, 19 November 2016 at 21:16:15 UTC, Dicebot wrote:
DIP 1003 is merged to the queue and open for public informal 
feedback.


Perhaps a good idea for D3...