Re: Why does nobody seem to think that `null` is a serious problem in D?

2018-11-30 Thread 12345swordy via Digitalmars-d-learn

On Friday, 30 November 2018 at 12:00:46 UTC, Atila Neves wrote:

On Thursday, 29 November 2018 at 18:31:41 UTC, SimonN wrote:
On Monday, 19 November 2018 at 21:23:31 UTC, Jordi Gutiérrez 
Hermoso wrote:
When I was first playing with D, I managed to create a 
segfault



What's the reasoning for allowing this?


100 % agree that there should be non-nullable class 
references, they're my main missing feature in D. Likewise, 
I'm astonished that only few D users wish for them.


https://github.com/aliak00/optional/blob/master/source/optional/notnull.d

"But I don't like the verbosity!"

alias MyClass = NotNullable!MyClassImpl;


Huh neat, though it would nice to allow conversion of Nullable to 
NotNullable via runtime conditional checking.


NotNullable!MyClassImpl = (MyClassImpvar != Null) ? MyClassImpvar 
: new MyClassImpvar();


Re: Why does nobody seem to think that `null` is a serious problem in D?

2018-11-30 Thread 12345swordy via Digitalmars-d-learn

On Friday, 30 November 2018 at 15:32:55 UTC, 12345swordy wrote:

On Friday, 30 November 2018 at 12:00:46 UTC, Atila Neves wrote:

On Thursday, 29 November 2018 at 18:31:41 UTC, SimonN wrote:
On Monday, 19 November 2018 at 21:23:31 UTC, Jordi Gutiérrez 
Hermoso wrote:

[...]



[...]


100 % agree that there should be non-nullable class 
references, they're my main missing feature in D. Likewise, 
I'm astonished that only few D users wish for them.


https://github.com/aliak00/optional/blob/master/source/optional/notnull.d

"But I don't like the verbosity!"

alias MyClass = NotNullable!MyClassImpl;


Huh neat, though it would nice to allow conversion of Nullable 
to NotNullable via runtime conditional checking.


NotNullable!MyClassImpl = (MyClassImpvar != Null) ? 
MyClassImpvar : new MyClassImpvar();

I meant new MyClassImp(), but you get the idea.


Re: serve-d break on every update of vs code

2018-11-30 Thread Laurent Tréguier via Digitalmars-d-learn

On Friday, 30 November 2018 at 13:04:37 UTC, greatsam4sure wrote:
vs code update every time I am connected to internet. Each time 
I accept the update my code-d stops to show autocomplete. what 
is the best way to solve this problem.


Just updated today. These are the error report



Installing into C:\Users\Greatsam\AppData\Roaming\code-d\bin
git clone --recursive https://github.com/Pure-D/serve-d.git 
serve-d

Cloning into 'serve-d'...

dub upgrade
Upgrading project in 
C:\Users\Greatsam\AppData\Roaming\code-d\bin\serve-d

dub build --arch=x86_mscoff

Running pre-generate commands for dfmt...
Running pre-generate commands for dscanner...
Performing "debug" build using dmd for x86, x86_mscoff.
[...]


If you need to keep your dmd at a version that can't compile it, 
there is a precompiled binary for Windows in the Github releases


Re: what are the rules for @nogc and @safe attributes inference?

2018-11-30 Thread Neia Neutuladh via Digitalmars-d-learn
On Fri, 30 Nov 2018 20:41:03 +, ikod wrote:
> I can't find the reason why nogc/nothrow can't be inferred in this case:
> 
> class S(K,V)
> {
>  auto get/*()*/(K a) {
>  return 0;
>  }
> }
> void main() @nogc nothrow {
>  S!(int, string) sia;
>  auto v = sia.get(1);
> }

class Nefarious : S!(int, string)
{
  override int get(int a)
  {
// Whoops, I used the GC
return new char[a].length;
  }
}

The compiler can't prove that a variable of type S!(int, string) will not 
be of type Nefarious, which uses the GC, so it can't infer @nogc for S.get.

However, if you make the function final, then the compiler can infer it to 
be pure nothrow @nogc @safe.

Or if you use a struct instead of a class, structs don't do inheritance, 
so the compiler can infer attributes without worrying about nefarious 
inheritance.

> But everything is ok if you uncomment parentheses after get.

Templated functions are implicitly final.


Re: serve-d break on every update of vs code

2018-11-30 Thread greatsam4sure via Digitalmars-d-learn

On Friday, 30 November 2018 at 14:38:14 UTC, WebFreak001 wrote:
On Friday, 30 November 2018 at 13:04:37 UTC, greatsam4sure 
wrote:
vs code update every time I am connected to internet. Each 
time I accept the update my code-d stops to show autocomplete. 
what is the best way to solve this problem.


[...]


hi,

update dmd


I am using dmd 2.083. What can I do next


Re: what are the rules for @nogc and @safe attributes inference?

2018-11-30 Thread ikod via Digitalmars-d-learn

On Friday, 30 November 2018 at 21:03:06 UTC, Neia Neutuladh wrote:

On Fri, 30 Nov 2018 20:41:03 +, ikod wrote:
I can't find the reason why nogc/nothrow can't be inferred in 
this case:


class S(K,V)
{
 auto get/*()*/(K a) {
 return 0;
 }
}
void main() @nogc nothrow {
 S!(int, string) sia;
 auto v = sia.get(1);
}


class Nefarious : S!(int, string)
{
  override int get(int a)
  {
// Whoops, I used the GC
return new char[a].length;
  }
}

The compiler can't prove that a variable of type S!(int, 
string) will not be of type Nefarious, which uses the GC, so it 
can't infer @nogc for S.get.


However, if you make the function final, then the compiler can 
infer it to be pure nothrow @nogc @safe.


Or if you use a struct instead of a class, structs don't do 
inheritance, so the compiler can infer attributes without 
worrying about nefarious inheritance.



But everything is ok if you uncomment parentheses after get.


Templated functions are implicitly final.


Thanks for explanation, got it.

My case is actually

interface I(K,V)
{
int get()(K);
}
class S(K,V) : I!(K, V)
{
int v;
int get()(K a)
{
return v;
}
}
void main() nothrow
{
S!(int, string) s = new S!(int, string);
s.get(1);
}

My goal is to allow compiler to infer all properties of s.get 
without adding nothrow/nogc anywhere.  And these templated 
functions is only way it works for me. Is it ok? Or there is 
better solution?


Thanks!


Re: serve-d break on every update of vs code

2018-11-30 Thread greatsam4sure via Digitalmars-d-learn
On Friday, 30 November 2018 at 16:24:35 UTC, Laurent Tréguier 
wrote:
On Friday, 30 November 2018 at 13:04:37 UTC, greatsam4sure 
wrote:
vs code update every time I am connected to internet. Each 
time I accept the update my code-d stops to show autocomplete. 
what is the best way to solve this problem.


Just updated today. These are the error report



Installing into C:\Users\Greatsam\AppData\Roaming\code-d\bin

[...]

Cloning into 'serve-d'...

[...]
Upgrading project in 
C:\Users\Greatsam\AppData\Roaming\code-d\bin\serve-d

[...]

Running pre-generate commands for dfmt...
Running pre-generate commands for dscanner...
Performing "debug" build using dmd for x86, x86_mscoff.
[...]


If you need to keep your dmd at a version that can't compile 
it, there is a precompiled binary for Windows in the Github 
releases



Plz I need more explanation


Template matches more than one template declaration error when trying to pass function's pointer

2018-11-30 Thread solidstate1991 via Digitalmars-d-learn
After some refactoring, there are four functions sharing the same 
name (technically four, but LDC didn't complain about them):


@nogc void blitter(T)(T* src, T* dest, size_t length){...}

and

@nogc void blitter(T)(T* src, T* dest, size_t length, T* 
mask){...}


I need the first one, but at compilation time I get the following 
error:


pixelperfectengine\src\PixelPerfectEngine\graphics\layers.d(61,30): Error: 
template CPUblit.composing.blitter matches more than one template declaration:
..\..\..\AppData\Local\dub\packages\cpublit-0.2.3\cpublit\src\CPUblit\composing.d(2006,19):
 blitter(T)(T* src, T* dest, size_t length)
and
..\..\..\AppData\Local\dub\packages\cpublit-0.2.3\cpublit\src\CPUblit\composing.d(2274,19):
 blitter(T)(T* src, T* dest, size_t length, T* mask)


Re: serve-d break on every update of vs code

2018-11-30 Thread greatsam4sure via Digitalmars-d-learn

On Friday, 30 November 2018 at 23:02:13 UTC, WebFreak001 wrote:
On Friday, 30 November 2018 at 22:37:02 UTC, greatsam4sure 
wrote:
On Friday, 30 November 2018 at 16:24:35 UTC, Laurent Tréguier 
wrote:
On Friday, 30 November 2018 at 13:04:37 UTC, greatsam4sure 
wrote:
vs code update every time I am connected to internet. Each 
time I accept the update my code-d stops to show 
autocomplete. what is the best way to solve this problem.


Just updated today. These are the error report



Installing into C:\Users\Greatsam\AppData\Roaming\code-d\bin

[...]

Cloning into 'serve-d'...

[...]
Upgrading project in 
C:\Users\Greatsam\AppData\Roaming\code-d\bin\serve-d

[...]

Running pre-generate commands for dfmt...
Running pre-generate commands for dscanner...
Performing "debug" build using dmd for x86, x86_mscoff.
[...]


If you need to keep your dmd at a version that can't compile 
it, there is a precompiled binary for Windows in the Github 
releases



Plz I need more explanation


Are you running vscode in some kind of sandbox like a flatpak 
or something? Try running dmd --version and send the output.


To validate, try manually compiling serve-d:

git clone --recursive https://github.com/Pure-D/serve-d.git 
serve-d

cd serve-d
dub build --arch=x86_mscoff


 Sorry, I am not using dmd 2.083 but 2.080. I just check and 
update it.
It is a mistake on my part. I was using dmd 2.083 before but due 
to link error with vibe.d 0.8.4, I change it.


It is just show installing DCD for a long time without installing 
it. I guess it is network issue. I think it will install later





Re: serve-d break on every update of vs code

2018-11-30 Thread WebFreak001 via Digitalmars-d-learn

On Friday, 30 November 2018 at 22:37:02 UTC, greatsam4sure wrote:
On Friday, 30 November 2018 at 16:24:35 UTC, Laurent Tréguier 
wrote:
On Friday, 30 November 2018 at 13:04:37 UTC, greatsam4sure 
wrote:
vs code update every time I am connected to internet. Each 
time I accept the update my code-d stops to show 
autocomplete. what is the best way to solve this problem.


Just updated today. These are the error report



Installing into C:\Users\Greatsam\AppData\Roaming\code-d\bin

[...]

Cloning into 'serve-d'...

[...]
Upgrading project in 
C:\Users\Greatsam\AppData\Roaming\code-d\bin\serve-d

[...]

Running pre-generate commands for dfmt...
Running pre-generate commands for dscanner...
Performing "debug" build using dmd for x86, x86_mscoff.
[...]


If you need to keep your dmd at a version that can't compile 
it, there is a precompiled binary for Windows in the Github 
releases



Plz I need more explanation


Are you running vscode in some kind of sandbox like a flatpak or 
something? Try running dmd --version and send the output.


To validate, try manually compiling serve-d:

git clone --recursive https://github.com/Pure-D/serve-d.git 
serve-d

cd serve-d
dub build --arch=x86_mscoff


Re: Template matches more than one template declaration error when trying to pass function's pointer

2018-11-30 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Dec 01, 2018 at 01:17:55AM +, solidstate1991 via 
Digitalmars-d-learn wrote:
> After some refactoring, there are four functions sharing the same name
> (technically four, but LDC didn't complain about them):
> 
> @nogc void blitter(T)(T* src, T* dest, size_t length){...}
> 
> and
> 
> @nogc void blitter(T)(T* src, T* dest, size_t length, T* mask){...}
> 
> I need the first one, but at compilation time I get the following
> error:
> 
> pixelperfectengine\src\PixelPerfectEngine\graphics\layers.d(61,30): Error: 
> template CPUblit.composing.blitter matches more than one template declaration:
> ..\..\..\AppData\Local\dub\packages\cpublit-0.2.3\cpublit\src\CPUblit\composing.d(2006,19):
>  blitter(T)(T* src, T* dest, size_t length)
> and
> ..\..\..\AppData\Local\dub\packages\cpublit-0.2.3\cpublit\src\CPUblit\composing.d(2274,19):
>  blitter(T)(T* src, T* dest, size_t length, T* mask)

For non-template overloaded functions, you can get the address by
casting the function pointer, e.g.:

void fun(int size) {
writeln("1");
}

void fun(int size, float z) {
writeln("2");
}

auto p1 = cast(void function(int)) 
auto p2 = cast(void function(int, float)) 
auto p3 = cast(void function(int, string)) 

p1(0);  // prints "1"
p2(0, 0f);  // prints "2"
p3(0, "");  // prints "1" (!)

It's sorta weird when the cast doesn't match any overload; the compiler
seems to just arbitrarily select the first one.

However, for template functions, casting isn't enough; you need
__traits(getOverloads):

alias ovs = __traits(getOverloads, myModule, "gun", true);
foreach (ov; ovs) {
writeln(ov.stringof);
}

prints:

gun(T)(T t, int size)
gun(T)(T t, int size, float z)

But actually coaxing the address out of the function is rather ugly:

// These don't work:
//auto q = [0]!int;
//auto q = &(ovs[0]!int);
//auto q = &(ovs[0])!int;
// ... etc.

// But this does:
alias ov1 = ovs[1];
auto q = !int;
q(0, 1, 1f);// prints "4"

However, there appears to be a bug: if you try to access the first
overload, it doesn't work again! 

// But this does:
alias ov0 = ovs[0]; // NG: compile error!
auto q = !int;
q(0, 1, 1f);

Sounds like a compiler bug should be filed. :-/

I tried to hack it by using AliasSeq to insert a dummy first element to
the sequence then using [1] to access the first overload, but got the
same error. I guess internally somehow the compiler isn't treating the
first overload case correctly, independently of its position in the
tuple / AliasSeq.


T

-- 
Nearly all men can stand adversity, but if you want to test a man's character, 
give him power. -- Abraham Lincoln


Re: what are the rules for @nogc and @safe attributes inference?

2018-11-30 Thread Neia Neutuladh via Digitalmars-d-learn
On Fri, 30 Nov 2018 22:10:11 +, ikod wrote:
> Thanks for explanation, got it.
> 
> My case is actually
> 
> interface I(K,V)
> {
>  int get()(K);
> }

Interface functions must be abstract. Templated functions are implicitly 
final. Final things can't be abstract.

If there's something about types K and V that determine whether you should 
be able to use the GC or not, you'll have to encode that explicitly.


Re: Why does nobody seem to think that `null` is a serious problem in D?

2018-11-30 Thread Tony via Digitalmars-d-learn
isocpp.org just had a link to a blog post where someone makes a 
case for uninitialized variables in C++ being an advantage in 
that you can potentially get a warning regarding use of an 
uninitialized variable that points out an error in your code.


https://akrzemi1.wordpress.com/2018/11/22/treating-symptoms-instead-of-the-cause/




Re: getopt short-options documentation

2018-11-30 Thread Antonio Corbi via Digitalmars-d-learn

On Thursday, 29 November 2018 at 20:55:22 UTC, Daniel Kozak wrote:
Are you sure? Can you show me an example? I always forgot on 
this limitation and somtimes it cause really nesty things :D


On Thu, Nov 29, 2018 at 6:05 PM Antonio Corbi via 
Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote:



Hi!

Reading through the `getopt` documentation at one point it 
says:


   "Forms such as -t 5 and -timeout=5 will be not accepted."

But I'm able to to use short options like '-t 5' (with spaces 
between the 't' and the '5'). It seems that this limitation 
has been eliminated and it just-works-now, is it so?


Thx!


Hi Daniel!

Try this one :
---
module tools.trainer;

import std.stdio, std.getopt;

//
// Main Program //
//-
int main(string[] args) {

  dcharletter = 'ñ';
  string[] inputFiles;
  string[] cmpFiles;


  arraySep = ",";  // defaults to "", separation by whitespace
  auto helpInformation = getopt(args,
"letter|l", "The char that 
represent the input images.", ,
"inputf|i", "The files that 
represent the image of the same char.", ,
"cmpf|c",   "The files that 
represent images of other chars to compare with.", );


  if (helpInformation.helpWanted) {
defaultGetoptPrinter("Some information about the program.",
 helpInformation.options);
  }

  writeln("Letter selected is: ", letter);
  return 0;
}
-

trainer -l Y
trainer -lY

Both of them work for me.

Antonio


Re: gcc 9 vs. dmd?

2018-11-30 Thread welkam via Digitalmars-d-learn
On Friday, 30 November 2018 at 04:47:26 UTC, Andrew Pennebaker 
wrote:


gcc is currently required for dmd on FreeBSD, as dmd links to 
libstdc++.


Parts of dmd are still written in C++ but most of it was 
converted recently. More on that here:

"DMD backend now in D"
https://forum.dlang.org/thread/psaekt$tah$1...@digitalmars.com


Re: How to pass -J switch to compiler via DUB?

2018-11-30 Thread rikki cattermole via Digitalmars-d-learn

On 01/12/2018 12:05 AM, Andrey wrote:

Hi,
How to pass -J switch to compiler via DUB?
I want to import some text file at compile time:

string data = import("vertex.glsl");


In dub.json:
"dflags": [
     "-J=vertex.glsl"
]

The file itself is located on the same level as "dub.json".


stringImportPaths


How to pass -J switch to compiler via DUB?

2018-11-30 Thread Andrey via Digitalmars-d-learn

Hi,
How to pass -J switch to compiler via DUB?
I want to import some text file at compile time:

string data = import("vertex.glsl");


In dub.json:
"dflags": [
"-J=vertex.glsl"
]

The file itself is located on the same level as "dub.json".


Re: How to pass -J switch to compiler via DUB?

2018-11-30 Thread fghost via Digitalmars-d-learn

On Friday, 30 November 2018 at 11:05:26 UTC, Andrey wrote:

Hi,
How to pass -J switch to compiler via DUB?
I want to import some text file at compile time:

string data = import("vertex.glsl");


In dub.json:
"dflags": [
"-J=vertex.glsl"
]

The file itself is located on the same level as "dub.json".


The -J switch takes a directory path, not path to the file 
directly.


Re: gcc 9 vs. dmd?

2018-11-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, November 30, 2018 2:43:41 AM MST welkam via Digitalmars-d-learn 
wrote:
> On Friday, 30 November 2018 at 04:47:26 UTC, Andrew Pennebaker
>
> wrote:
> > gcc is currently required for dmd on FreeBSD, as dmd links to
> > libstdc++.
>
> Parts of dmd are still written in C++ but most of it was
> converted recently. More on that here:
> "DMD backend now in D"
> https://forum.dlang.org/thread/psaekt$tah$1...@digitalmars.com

That and the C/C++ compiler could be clang rather than gcc. Even without the
backend being ported to D, there shouldn't be an actual dependency on gcc
specifically (especially on FreeBSD where you may not even have gcc
installed). But if I understand correctly, dmd has always used the C
compiler to link on *nix systems rather than using the linker directly. I
don't know why it does, but linking via the C compiler is a completely
different issue from integrating with it.

Regardless, as to the OP's question about gcc integration, that really
doesn't have much to do with dmd. That's a big step forward for gdc, but dmd
is the reference compiler. It's where everything is implemented. gdc and ldc
are then alternate compilers that use the same front-end. but they're
separate projects, and there's really no benefit to us at this point to
removing dmd in favor of either of the other two. With dmd, we're in full
control of the code and the release cycle, which is not true with llvm or
gcc. Honestly, as great as it is for gdc to end up in the official gcc
release, in practice, I expect that it's going to be a recipe for a portion
of the community using an outdated version of the language (especially when
coupled with stuff like LTS releases for Linux distros). That's already been
a problem with gdc even without it being in the official gcc release due to
how long it's taken them to catch up after the front-end was converted to D.

Also, dmd's backend is the backend that Walter wrote and has used for
decades - and it's part of dmc, which he still sells. So, I don't think that
he's going to be in hurry to drop it. And if he were, I honestly expect that
ldc would have become the reference compiler a while ago, not gdc. But dmd
continues to be the reference compiler, and while improving its backend is
not the focus, Walter still does work on it (and part of the reason that
he's converted it to D is so that he can more easily improve it).
Historically, Walter has wanted to stay away from gcc and clang code (or the
code of any other compiler that isn't his), because in the past, he's found
that being able to say that he's never read the source code has been a good
defense against any kind of accusation of code stealing (which definitely
matters when he's selling a C++ compiler). So, all the signs are that we're
going to continue to have the choice of dmd, ldc, and gdc, and none of them
are going anywhere.

- Jonathan M Davis





Re: How to pass -J switch to compiler via DUB?

2018-11-30 Thread Andrey via Digitalmars-d-learn

On Friday, 30 November 2018 at 11:21:04 UTC, fghost wrote:

On Friday, 30 November 2018 at 11:05:26 UTC, Andrey wrote:

Hi,
How to pass -J switch to compiler via DUB?
I want to import some text file at compile time:

string data = import("vertex.glsl");


In dub.json:
"dflags": [
"-J=vertex.glsl"
]

The file itself is located on the same level as "dub.json".


The -J switch takes a directory path, not path to the file 
directly.


Thanks to all.


Re: Why does nobody seem to think that `null` is a serious problem in D?

2018-11-30 Thread Atila Neves via Digitalmars-d-learn

On Thursday, 29 November 2018 at 18:31:41 UTC, SimonN wrote:
On Monday, 19 November 2018 at 21:23:31 UTC, Jordi Gutiérrez 
Hermoso wrote:

When I was first playing with D, I managed to create a segfault



What's the reasoning for allowing this?


100 % agree that there should be non-nullable class references, 
they're my main missing feature in D. Likewise, I'm astonished 
that only few D users wish for them.


https://github.com/aliak00/optional/blob/master/source/optional/notnull.d

"But I don't like the verbosity!"

alias MyClass = NotNullable!MyClassImpl;



Re: Why does nobody seem to think that `null` is a serious problem in D?

2018-11-30 Thread Atila Neves via Digitalmars-d-learn

On Friday, 30 November 2018 at 06:15:29 UTC, O-N-S (ozan) wrote:

On Monday, 19 November 2018 at 21:23:31
On Monday, 19 November 2018 at 21:23:31 UTC, Jordi Gutiérrez 
Hermoso wrote:


I'm not the only one who has done this. I can't find it right 
now, but I've seen at least one person open a bug report 
because they misunderstood this as a bug in dmd.


I have been told a couple of times that this isn't something 
that needs to be patched in the language, but I don't 
understand. It seems like a very easy way to generate a 
segfault (and not a NullPointerException or whatever).




I love Null in an empty class variable and I use it very often 
in my code. It simplifies a lot.


What would be a better way? (practical not theoretical)

Regards Ozan


A better way is to always initialise.

Invalid states should be unrepresentable.


serve-d break on every update of vs code

2018-11-30 Thread greatsam4sure via Digitalmars-d-learn
vs code update every time I am connected to internet. Each time I 
accept the update my code-d stops to show autocomplete. what is 
the best way to solve this problem.


Just updated today. These are the error report



Installing into C:\Users\Greatsam\AppData\Roaming\code-d\bin
git clone --recursive https://github.com/Pure-D/serve-d.git 
serve-d

Cloning into 'serve-d'...

dub upgrade
Upgrading project in 
C:\Users\Greatsam\AppData\Roaming\code-d\bin\serve-d

dub build --arch=x86_mscoff

Running pre-generate commands for dfmt...
Running pre-generate commands for dscanner...
Performing "debug" build using dmd for x86, x86_mscoff.
diet-complete 0.0.1: building configuration "library"...
..\..\..\..\Local\dub\packages\diet-complete-0.0.1\diet-complete\source\dietc\complete.d(409,43):
 Error: statement expected to be `{ }`, not `(`
..\..\..\..\Local\dub\packages\diet-complete-0.0.1\diet-complete\source\dietc\complete.d(409,50):
 Error: template argument expected following `!`
..\..\..\..\Local\dub\packages\diet-complete-0.0.1\diet-complete\source\dietc\complete.d(409,50):
 Error: found `is` when expecting `)`
..\..\..\..\Local\dub\packages\diet-complete-0.0.1\diet-complete\source\dietc\complete.d(409,53):
 Error: missing `{ ... }` for function literal
..\..\..\..\Local\dub\packages\diet-complete-0.0.1\diet-complete\source\dietc\complete.d(409,53):
 Error: found `null` when expecting `;` following statement
..\..\..\..\Local\dub\packages\diet-complete-0.0.1\diet-complete\source\dietc\complete.d(409,57):
 Error: declaration expected, not `)`
..\..\..\..\Local\dub\packages\diet-complete-0.0.1\diet-complete\source\dietc\complete.d(413,9):
 Error: no identifier for declarator `code`
..\..\..\..\Local\dub\packages\diet-complete-0.0.1\diet-complete\source\dietc\complete.d(413,9):
 Error: declaration expected, not `~=`
..\..\..\..\Local\dub\packages\diet-complete-0.0.1\diet-complete\source\dietc\complete.d(414,4):
 Error: declaration expected, not `if`
..\..\..\..\Local\dub\packages\diet-complete-0.0.1\diet-complete\source\dietc\complete.d(417,16):
 Error: unexpected `(` in declarator
..\..\..\..\Local\dub\packages\diet-complete-0.0.1\diet-complete\source\dietc\complete.d(417,22):
 Error: no identifier for declarator `stmt.accept(this)`
..\..\..\..\Local\dub\packages\diet-complete-0.0.1\diet-complete\source\dietc\complete.d(418,10):
 Error: no identifier for declarator `code`
..\..\..\..\Local\dub\packages\diet-complete-0.0.1\diet-complete\source\dietc\complete.d(418,10):
 Error: declaration expected, not `~=`
..\..\..\..\Local\dub\packages\diet-complete-0.0.1\diet-complete\source\dietc\complete.d(423,35):
 Error: statement expected to be `{ }`, not `(`
..\..\..\..\Local\dub\packages\diet-complete-0.0.1\diet-complete\source\dietc\complete.d(423,42):
 Error: template argument expected following `!`
..\..\..\..\Local\dub\packages\diet-complete-0.0.1\diet-complete\source\dietc\complete.d(423,42):
 Error: found `is` when expecting `)`
..\..\..\..\Local\dub\packages\diet-complete-0.0.1\diet-complete\source\dietc\complete.d(423,45):
 Error: missing `{ ... }` for function literal
..\..\..\..\Local\dub\packages\diet-complete-0.0.1\diet-complete\source\dietc\complete.d(423,45):
 Error: found `null` when expecting `;` following statement
..\..\..\..\Local\dub\packages\diet-complete-0.0.1\diet-complete\source\dietc\complete.d(423,49):
 Error: declaration expected, not `)`
..\..\..\..\Local\dub\packages\diet-complete-0.0.1\diet-complete\source\dietc\complete.d(426,5):
 Error: declaration expected, not `if`
dmd failed with exit code 1.
Failed to install serve-d (Error code 2)



Re: what are the rules for @nogc and @safe attributes inference?

2018-11-30 Thread ikod via Digitalmars-d-learn
On Thursday, 15 November 2018 at 21:55:18 UTC, Steven 
Schveighoffer wrote:

On 11/15/18 4:09 PM, Adam D. Ruppe wrote:

On Thursday, 15 November 2018 at 21:00:48 UTC, ikod wrote:

what are the rules for @nogc inference?


It attempts it if and only if it is a template.


Well, the general "rule" is, if it's code that must be 
available to the compiler when it's called, then it will be 
inferred.


Examples of code that must be processed every time it's used:

1. Template functions
2. auto-returning functions
3. functions inside templates (like member functions of a 
templated struct)

4. Inner functions

There may be others I didn't think of.

Everything else must be manually attributed. The reasoning is 
that the function may be stubbed in a .di file, and in that 
case, attribute inference wouldn't be possible.


-Steve


Hello, Steve!

I can't find the reason why nogc/nothrow can't be inferred in 
this case:


class S(K,V)
{
auto get/*()*/(K a)
{
return 0;
}
}
void main() @nogc nothrow
{
S!(int, string) sia;
auto v = sia.get(1);
}

But everything is ok if you uncomment parentheses after get. get 
is already a member of templated class, what can be wrong with 
this code?


Thanks!


Re: serve-d break on every update of vs code

2018-11-30 Thread WebFreak001 via Digitalmars-d-learn

On Friday, 30 November 2018 at 13:04:37 UTC, greatsam4sure wrote:
vs code update every time I am connected to internet. Each time 
I accept the update my code-d stops to show autocomplete. what 
is the best way to solve this problem.


[...]


hi,

update dmd