Re: What would be the advantage of using D to port some games?

2020-07-20 Thread Laurent Tréguier via Digitalmars-d-learn

On Monday, 20 July 2020 at 19:49:52 UTC, RegeleIONESCU wrote:

Hello!

I was wondering why some game related packages/libraries are 
not being developed anymore or are kind of paused. Fore example 
the last version of derelict-sdl2 is an alpha from May 2018. 
Lack of people to develop it, to take care of it or is kind of 
language focus shift?


The derelict-* packages are being superseded by bindbc-* packages 
as far as I know, so bindbc-sdl is probably what you want now: 
https://code.dlang.org/packages/bindbc-sdl


Re: total newbie + IDE

2020-02-09 Thread Laurent Tréguier via Digitalmars-d-learn

On Sunday, 9 February 2020 at 22:10:57 UTC, solnce wrote:
No, I understand that and agree - VSCode is impressive and I'll 
try it, but what is wrong with idea to have a dedicated IDE? At 
least one. C/C++ has tons of these and many of these are being 
actively developed, so why D cannot have? Especially when it is 
aiming to replace C/C++. Argument that VSCode is pretty much 
enough for most task it is ok, but is not very valid. The same 
applies to D itself - why to make a new language then when 
there is C++ around and there is a tons of IDE's for it.


Personally I feel this is more about lack of the vision, as 
Alexandrescu once said. Now it feels like D is mostly the 
compiler, but I think, that having one big mega project (like 
IDE+RAD) could give a new breath and significance to D language.


Making an entire IDE would be a lot of work. Making plugins for 
existing editors is already time consuming, and is less work than 
building a complete solution.
Given how powerful regular editors can be, whether it's VSCode, 
Vim or Emacs, plugins make for a good compromise bewteen the time 
spent making the plugin, and the result you get.


Re: Undefined symbol: _dyld_enumerate_tlv_storage (OSX)

2019-10-11 Thread Laurent Tréguier via Digitalmars-d-learn

On Thursday, 10 October 2019 at 18:31:25 UTC, Daniel Kozak wrote:

What dmd version?

https://issues.dlang.org/show_bug.cgi?id=20019


Ah, I should have read this before replying; that's precisely the 
issue I had.


Re: Undefined symbol: _dyld_enumerate_tlv_storage (OSX)

2019-10-11 Thread Laurent Tréguier via Digitalmars-d-learn
On Thursday, 10 October 2019 at 18:12:51 UTC, Robert M. Münch 
wrote:
I have two project I want to compile and both times get this 
error:


Undefined symbols for architecture x86_64:
 "_dyld_enumerate_tlv_storage", referenced from:
 __d_dyld_getTLSRange in libphobos2.a(osx_tls.o)

I'm wondering where this comes from as I didn't see it in the 
past. Any idea?


I had the same missing symbol at runtime, when trying to run an 
already compiled binary (LDC 1.16 I think) after a Catalina 
update. In that case, recompiling (LDC 1.17 or DMD 2.088.0) was 
apparently enough to mitigate the issue.


Re: DLS server can't install on my pc

2019-05-24 Thread Laurent Tréguier via Digitalmars-d-learn

On Wednesday, 22 May 2019 at 12:59:13 UTC, greatsam4sure wrote:
I am having some difficulty installing DLS for dlang 1.16.4 the 
visual studio code plugin for Dlang on my pc-windows 10 Lenovo 
laptop ci7. it actually install in my ci3 running windows 10. 
It says this app can't install on this pc.



I will be appreciate any help


I just launched VSCode on Windows, and Windows Defender started 
telling me that DLS v0.25.9 contained a Trojan. The releases are 
automated and produced by AppVeyor [1], so it should probably be 
a false positive. Maybe this is what happened to you ?


A new patch (v0.25.10) is out now, and my Windows Defender 
doesn't seem to consider that one a threat apparently.



[1] https://ci.appveyor.com/project/dlanguageserver/dls


Re: DLS server can't install on my pc

2019-05-24 Thread Laurent Tréguier via Digitalmars-d-learn

On Wednesday, 22 May 2019 at 12:59:13 UTC, greatsam4sure wrote:
I am having some difficulty installing DLS for dlang 1.16.4 the 
visual studio code plugin for Dlang on my pc-windows 10 Lenovo 
laptop ci7. it actually install in my ci3 running windows 10. 
It says this app can't install on this pc.



I will be appreciate any help


I have a few questions to clarify some things:
- What is the exact edition of Windows you are using ?
- What is your processor's architecture ? (DLS only supports 
x86_64 processors)
- What do you get from manually running `dub fetch dls; dub run 
dls:bootstrap` in a command prompt ?


Re: a way of approximating "API internal" visibility?

2019-05-18 Thread Laurent Tréguier via Digitalmars-d-learn

On Saturday, 18 May 2019 at 06:23:37 UTC, DanielG wrote:
I'm working on a library spread across multiple 
modules/packages.


Sometimes I have symbols that I would like to share between 
internal packages, but I don't want to make 'public' because 
then it would be exposed to the client-facing API. To a degree 
this could be gotten around by making things public internally, 
and then selectively 'public import'-ing individual symbols in 
the topmost client-facing module (vs. entire packages, as I'm 
doing now).


However I have the following situation for which that won't 
work: I have a class that's going to be visible to the client, 
but inside that class I have methods that should only be 
accessible to other internal packages. So neither 'public' nor 
'package' is what I want.


I already collapsed one level of what I was doing to get around 
this issue (putting things in a common package even though I 
would have preferred they be in separate, sibling packages), 
but I'm not sure I could do that again without making a mess.


Is there some way of approximating an access specifier between 
'package' and 'public'? Or am I likely just structuring things 
very badly to begin with, to even have this problem? I'm not 
much of a C++ guy but I'd probably resort to using 'friend' to 
get around this, at least in the case of classes.


Maybe what you need is `package(a.b.c)`?

```
my/lib/internal/foo.d

// This function should be visible from any package that has 
my.lib in its package hierarchy

package(my.lib) void func();
```

https://dlang.org/spec/attribute.html#visibility_attributes


However, I don't know what you could do if you want to share code 
between completely different package that don't have a common 
root.


Re: DCD 0 symbols cached?

2019-04-11 Thread Laurent Tréguier via Digitalmars-d-learn

On Wednesday, 10 April 2019 at 18:39:23 UTC, Tom wrote:


Total newbie to D, trying to get it to play nice with Neovim 
using ncm2-d and DCD.


Issue: DCD never caches any symbols even when I point it 
directly to DMD's include files. Hate to ask for tech support 
on this forum but it's all I've got, Googling has brought no 
luck.


Using dcd version v0.11.0




Output from dcd-server -I /usr/include/dmd/phobos -I 
/usr/include/dmd/druntime/import :


2019-04-10T11:34:43.386 [info] main.d:130:runServer Starting 
up...
2019-04-10T11:34:43.386 [info] main.d:157:runServer Cleaning up 
old socket file at /run/user/1000/dcd.socket
2019-04-10T11:34:43.387 [info] main.d:164:runServer Listening 
at /run/user/1000/dcd.socket
2019-04-10T11:34:43.387 [info] main.d:181:runServer Import 
directories:

/usr/include/dmd/phobos
/usr/include/dmd/druntime/import
2019-04-10T11:34:43.387 [info] main.d:187:runServer 0 symbols 
cached.
2019-04-10T11:34:43.387 [info] main.d:188:runServer Startup 
completed in 0 milliseconds.


Any tips or guidance would be greatly appreciated. Thank you.


IIRC, with the latest versions, DCD will import symbols lazily; 
so it should only start caching symbols when they have been used 
because of a client request.
Have you tried using dcd-client nonetheless to see if you can get 
any result?


Re: Has anyone tried making a QtCreator plugin for D and what is your experience?

2019-01-15 Thread Laurent Tréguier via Digitalmars-d-learn

On Saturday, 12 January 2019 at 20:10:40 UTC, Enjoys Math wrote:
On Saturday, 12 January 2019 at 16:09:22 UTC, Laurent Tréguier 
wrote:
On Saturday, 12 January 2019 at 15:16:25 UTC, Laurent Tréguier 
wrote:
QtCreator 4.8.0 introduced support for the LSP last month : 
https://blog.qt.io/blog/2018/12/06/qt-creator-4-8-0-released


I think I'm going to add it to the list of editors to look 
into and perhaps try to make a plugin for it.


Correction: a language server can simply be set up in the LSP 
plugin's options after the plugin has been enabled, so some 
amount of D support is achievable already.


I see your links. Would you like to work on this together?  
Social coding is more powerful than solo coding IMO.


Is it necessary to make a plugin though ? Syntax highlighting can 
be downloaded directly through QtCreator's syntax options, and 
then the new bundled LSP plugin can be configured directly to use 
any language server.


Re: Has anyone tried making a QtCreator plugin for D and what is your experience?

2019-01-12 Thread Laurent Tréguier via Digitalmars-d-learn
On Saturday, 12 January 2019 at 15:16:25 UTC, Laurent Tréguier 
wrote:
QtCreator 4.8.0 introduced support for the LSP last month : 
https://blog.qt.io/blog/2018/12/06/qt-creator-4-8-0-released


I think I'm going to add it to the list of editors to look into 
and perhaps try to make a plugin for it.


Correction: a language server can simply be set up in the LSP 
plugin's options after the plugin has been enabled, so some 
amount of D support is achievable already.


Re: Has anyone tried making a QtCreator plugin for D and what is your experience?

2019-01-12 Thread Laurent Tréguier via Digitalmars-d-learn

On Friday, 11 January 2019 at 18:52:14 UTC, Enjoys Math wrote:
I'm 5 years an expert at PyQt5 in conjunction with 
QtCreator-designed widgets.  Where D is lacking is a good GUI 
editor and GUI library support.


I am starting by building a python-based project called QDmt = 
Qt/D manager


It will do for you, in a cross-platform way, the laborious task 
of compiling the Qt framework from git:


https://wiki.qt.io/Building_Qt_5_from_Git

And also it will guide you through building Qt Creator itself.  
We can then use this tool to help us hack the Qt Creator code 
and make it work for D (assuming a plugin isn't enough).


Building Qt is quite essential, as I am unable to get OpenGL 
support without building it for example.


So not only will we get traffic from TDPL people but from 
others who are only familiar with Qt and had to build it for 
some reason.  This would then be the goto tool for that.


Then they will see firsthand how easy it is (at the click of a 
few buttons) to work with D.


This will cause a huge influx of users to dlang.org and a rift 
in the spacetime continuum!


QtCreator 4.8.0 introduced support for the LSP last month : 
https://blog.qt.io/blog/2018/12/06/qt-creator-4-8-0-released


I think I'm going to add it to the list of editors to look into 
and perhaps try to make a plugin for it.


Re: dscanner --ctags: local variables, functions, ... are now shown in vim/neovim Tagbar

2018-12-17 Thread Laurent Tréguier via Digitalmars-d-learn

On Sunday, 16 December 2018 at 09:59:12 UTC, David wrote:
I am wondering how I could display (nested) local variables and 
functions in vim's tagbar (majutsushi/tagbar) using dscanner? 
So far I only see gloable variables, functions, ...


=== script.d ==
import std.stdio;

enum globalEnum1  { A = 1, B = 2 }
enum globalEnum2  { C, D }
void globalFun(){ writeln("global"); }
double globalDouble = 2.3;
string globalString = "hi";

void main(){
  enum localEnum  { A = 1, B = 2 }
  void localFun(){ writeln("local"); }
  double localDouble = 2.3;
}
===

=== Tagbar shows: ===
◢ functions
globalFun()
main()

◢ globalEnum1 : enum
[enumerators]
A
B

◢ globalEnum2 : enum
[enumerators]
C
D

◢ variables
globalDouble
globalString
===


I think that's not possible right now, D-Scanner skips over body 
functions and unittest blocks to not clutter the tags with 
potentially lots of local names.


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: javascript or typescript

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

On Monday, 5 November 2018 at 02:51:19 UTC, Fred wrote:

hi,
my javascript skill is bad.
but i want to host some nodejs app

i am aware that there is converter to js like dtojs. but it is 
out of date.


i'd like to give d a try. is there any other converter 
available. a decent one.


I haven't personally tried it, but there is an example of 
compiling D to Javascript here : 
https://github.com/Ace17/dscripten


Re: anyway to set a const object after the fact?

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

On Tuesday, 30 October 2018 at 11:23:48 UTC, aliak wrote:
Guess I could do that. But would there be a difference if I 
just declared the restArgs as non const then? Given the 
objective is "set this var to point to this thing and not allow 
it to be set to point to anything else".


The difference with const is that you wouldn't be able to modify 
the array itself (by adding or removing arguments for example). 
But yes, you can still re-assign it multiple times using 
Rebindable, so the lambda solution is a better idea indeed.


Re: anyway to set a const object after the fact?

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

On Monday, 29 October 2018 at 21:50:32 UTC, aliak wrote:

Hi, so if you have this piece of code:

struct C {

  void f() {
string[] others;
const string[] restArgs;
foreach (i, arg; args) {
  if (isValidArg(arg)) {
restArgs = args[i + 1 .. $];
break;
  }
  others ~= arg;
}
// "others" is a list of args before the valid arg is 
encountered

// "restArgs" is a list that is the args after the valid arg
  }
}

Is there anyway to set a const object after declaring it in the 
above context?


Cheers,
- Ali


It looks like there is a Rebindable type for that in std.typecons 
: https://dlang.org/phobos/std_typecons.html#Rebindable


Re: Small or big dub packages

2018-10-29 Thread Laurent Tréguier via Digitalmars-d-learn

On Monday, 29 October 2018 at 11:31:55 UTC, Igor wrote:
Can someone tell me what are pros and cons of having multiple 
extra small dub packages that depend on each other versus one 
dub package that has a bunch of functionality? Good example for 
this is dlib (https://github.com/gecko0307/dlib). It has many 
functionalities that could be split into separate packages.


The way I see it the advantage of smaller packages is that 
users can pick and choose and and only have the code they 
really need in their project, but the con could become managing 
a lot of dependencies. Also I am not sure how compile time on 
clean project and previously compiled project would be affected.


I'd use subpackages in such cases. This way you can either have 
one dependency on the whole thing, or select only a few 
subpackages.


Re: Noob question about structs allocation

2018-10-15 Thread Laurent Tréguier via Digitalmars-d-learn

On Monday, 15 October 2018 at 04:14:24 UTC, IM wrote:

What is the effect of calling destroy?
- calling the destructor?
- deallocating the memory?
- both?


IIRC, it only calls the destructor, the GC will decide when to 
deallocate the memory.


Re: Converting a character to upper case in string

2018-09-21 Thread Laurent Tréguier via Digitalmars-d-learn

On Friday, 21 September 2018 at 13:32:54 UTC, NX wrote:
On Friday, 21 September 2018 at 12:34:12 UTC, Laurent Tréguier 
wrote:
I would probably go for std.utf.decode [1] to get the 
character and its length in code units, capitalize it, and 
concatenate the result with the rest of the string.


[1] https://dlang.org/phobos/std_utf.html#.decode


So by this I assume it is sufficient to work with dchars rather 
than graphemes?


--
import std.stdio;
import std.conv;
import std.string;
import std.uni;

size_t index = 1;
auto theString = "he\u0308llo, world";
auto theStringPart = theString[index .. $];
auto firstLetter = theStringPart.decodeGrapheme;
auto result = theString[0 .. index]
~ capitalize(firstLetter[].text)
~ theString[index + graphemeStride(theString, index) .. $];
writeln(result);
--

This will capitalize graphemes as a whole, and might be better 
than what I previously wrote.


Re: Converting a character to upper case in string

2018-09-21 Thread Laurent Tréguier via Digitalmars-d-learn

On Friday, 21 September 2018 at 13:32:54 UTC, NX wrote:
On Friday, 21 September 2018 at 12:34:12 UTC, Laurent Tréguier 
wrote:
I would probably go for std.utf.decode [1] to get the 
character and its length in code units, capitalize it, and 
concatenate the result with the rest of the string.


[1] https://dlang.org/phobos/std_utf.html#.decode


So by this I assume it is sufficient to work with dchars rather 
than graphemes?


From what I've tested; it seems sufficient. I might be wrong 
though, I'm no unicode expert. It might still be a good idea to 
have a look at grapheme related functions.


Re: Converting a character to upper case in string

2018-09-21 Thread Laurent Tréguier via Digitalmars-d-learn

On Friday, 21 September 2018 at 12:15:52 UTC, NX wrote:
How can I properly convert a character, say, first one to upper 
case in a unicode correct manner?
In which code level I should be working on? Grapheme? Or maybe 
code point is sufficient?


There are few phobos functions like asCapitalized() none of 
which are what I want.


--
import std.conv : to;
import std.stdio : writeln;
import std.string : capitalize;
import std.utf : decode;

size_t index = 1;
size_t oldIndex = index;
auto theString = "hëllo, world";
auto firstLetter = theString.decode(index);
auto result = theString[0 .. oldIndex] ~ 
capitalize(firstLetter.to!string) ~ theString[index .. $];

writeln(result);
--

(This could be a lot prettier, but this seems to basically work)


Re: Converting a character to upper case in string

2018-09-21 Thread Laurent Tréguier via Digitalmars-d-learn

On Friday, 21 September 2018 at 12:15:52 UTC, NX wrote:
How can I properly convert a character, say, first one to upper 
case in a unicode correct manner?
In which code level I should be working on? Grapheme? Or maybe 
code point is sufficient?


There are few phobos functions like asCapitalized() none of 
which are what I want.


I would probably go for std.utf.decode [1] to get the character 
and its length in code units, capitalize it, and concatenate the 
result with the rest of the string.


[1] https://dlang.org/phobos/std_utf.html#.decode


Re: dmd64 on Windows: how?

2018-08-10 Thread Laurent Tréguier via Digitalmars-d-learn

On Friday, 10 August 2018 at 12:15:55 UTC, Ivan Kazmenko wrote:

Hi,

How should I set up DMD to be able to `dmd -m64` on Windows 
nowadays?


I usually download the 7z, but it broke when I replaced my 
Visual Studio with 2017 edition.


Now, I tried the current 2.081.1 .exe installer.  It didn't 
propose any additional 64-bit related options.  After the 
installation, `dmd -m64` complains that the linker could not 
find `libcmt.lib`.


The previous time I tried finding the right `libcmt` and 
treating the subsequent errors, I failed to locate all the 
correct libraries in Microsoft's Visual Studio and SDKs.  This 
time, I'd rather follow some up-to-date guide than waste the 
time again.


So, what's the most current guide to make 64-bit linking work 
on Windows?  I'm fine with having to install more LLVM or MinGW 
or Microsoft stuff, I just don't seem to know what I need.


Ivan Kazmenko.


Did you have a look at the wiki ? It looks like the image shows 
what needs to be installed:

https://wiki.dlang.org/Installing_DMD#Installing_the_Microsoft_toolchain


Re: dmd64 on Windows: how?

2018-08-10 Thread Laurent Tréguier via Digitalmars-d-learn

On Friday, 10 August 2018 at 12:15:55 UTC, Ivan Kazmenko wrote:

Hi,

How should I set up DMD to be able to `dmd -m64` on Windows 
nowadays?


I usually download the 7z, but it broke when I replaced my 
Visual Studio with 2017 edition.


If you were using another Visual Studio version, since VS 2017 
operates differently, in a more modular fashion, you'll have to 
use the Visual Studio 2017 installer to modify your installation 
and add the correct Windows SDKs.
I'm not on my machine and haven't done this in quite some time, 
so I don't remember which package exactly is needed...
But if you have already done this however, then I don't know what 
the problem could be.


Re: Trying to use the libclang Dub package

2018-07-21 Thread Laurent Tréguier via Digitalmars-d-learn

On Friday, 20 July 2018 at 14:03:20 UTC, bachmeier wrote:
Yeah, I didn't need the symlink on a different machine with 
Ubuntu 18.04. After some digging around, I found that I had 
libclang1-3.9, libclang-dev, and libclang-common-3.9-dev 
installed. libclang1-3.9 installs libclang.so.1. The one I was 
missing was libclang-3.9-dev.


It's confusing and I think this could be handled better by the 
distro. But this is also one of the reasons I'm not a fan of 
dub. The user is left to sort through these dependencies 
themselves, and that means it's really not suitable for 
packages that link to C code (which is most of what I do). One 
of the main selling points of D is its C interoperability, but 
a lot of new users would walk away rather than trying to figure 
this out, concluding that D is buggy.


I don't think it's confusing, you will also need to install the 
development package if you are coding something in C. It's the 
same, except for the language being D instead of C. As D is 
advertised as a systems programming language, this doesn't seem 
confusing (to me, at least).


If a dub package uses a system library though, it can be hinted 
at by the `systemDependencies` key in `dub.json`/`dub.sdl`. The 
problem is, I don't think many packages actually use it and I 
agree that since it's too easy to overlook it, you're often left 
to figure everything out. It's not something you're likely to 
find out unless you are already looking for it.


Re: Trying to use the libclang Dub package

2018-07-20 Thread Laurent Tréguier via Digitalmars-d-learn

On Thursday, 19 July 2018 at 15:42:02 UTC, bachmeier wrote:
Found the problem. The libclang package is looking for 
/usr/lib/llvm-3.9/lib/libclang.so. For some reason, Ubuntu has 
libclang.so.1. Creating a symlink in that directory to 
libclang.so is a solution.


Do you have the development package (probably something like 
libclang-3.9-dev) installed ? Usually they are the ones 
containing the correct symlink (see 
https://forum.dlang.org/thread/ea9432f8d37a563bc4920d0bb8748ae7ab23dfd4.ca...@winder.org.uk)


Re: Idiomatic way to add examples to dub package

2018-04-27 Thread Laurent Tréguier via Digitalmars-d-learn

On Friday, 27 April 2018 at 10:18:53 UTC, drug wrote:
dub.selections.json shouldn't be included in case of library 
because it should be configured at import site. in case of 
application it has been configured and so dub.selections.json 
should be included. IMHO.


This is the way Rust packages handle their Cargo.lock file, if 
I'm not mistaken, and it seems reasonable to me


Re: Is using function() in templates possible at all?

2018-04-12 Thread Laurent Tréguier via Digitalmars-d-learn

On Thursday, 12 April 2018 at 11:53:21 UTC, Alex wrote:
On Thursday, 12 April 2018 at 11:17:01 UTC, Laurent Tréguier 
wrote:

If the function is declared with explicit parameter types:


There are cool things possible, if the param type is explicitly 
typed :)


´´´
import std.traits;

void main()
{
auto list = new SortedList!((Vector3 v) => v.y)();
list.foo(Vector3.init);
}

struct Vector3 { float x, y, z; }

class SortedList(alias comparer) if(is(ReturnType!comparer : 
float))

{
alias T = Parameters!comparer[0];

T[] array;

auto foo(T t)
{
// do stuff
}
}
´´´


Getting rid of redundancy. Now that's nice !


Re: Is using function() in templates possible at all?

2018-04-12 Thread Laurent Tréguier via Digitalmars-d-learn

On Thursday, 12 April 2018 at 00:05:26 UTC, Nicholas Wilson wrote:

There is, with template constraints:

class SortedList(T, alias comparer)
if(is(typeof(comparer(T.init) : int))
{
//...
}


If the function is declared with explicit parameter types:
```
auto list = new SortedList!(Vector3, (Vector3 v) => v.y)();
```

Then the template guard can even have a full type definition:
```
class SortedList(T, alias comparer)
if (is(typeof(comparer) :  int function(T)))
{
//...
}
```


Re: Initializing a class member that is an object

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

On Friday, 30 March 2018 at 11:14:32 UTC, ketmar wrote:
please, make an ER in bugzilla then. 'cause it will be lost 
here, and with ER we have a chance to eventually do that.


Will do.


Re: Initializing a class member that is an object

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

On Friday, 30 March 2018 at 11:04:59 UTC, ketmar wrote:
p.s.: still, it may be nice to warn user about that. 'cause 
such runtime initializations are really belong to static ctor. 
dunno, i'm ok both with warning and without it.


I simply think a word about it in the docs would be nice, since 
this is tricky if you come from another language that doesn't do 
this. Otherwise I'm fine with it (and it's not exactly hard to 
fix either)


Initializing a class member that is an object

2018-03-30 Thread Laurent Tréguier via Digitalmars-d-learn
Coming from a more Java-esque background, I'm used to sometimes 
initializing class members outside of the constructor :


class MyClass {
Object member = new Object();
}

I've tried using this in D, but I've come to realize it acts very 
differently. In Java, the `new Object()` will be executed every 
time a new `MyClass` object is instantiated. In D however, it 
seems to be executed once, and members of every `MyClass` object 
will then be initialized with a reference to that one unique 
`Object`.


Example: https://run.dlang.io/is/Qlx2xY

Is this behavior really intentional ? I don't really see how it 
could be useful, and it's really confusing at first to see new 
objects with weird values even if none of their members has been 
touched yet...