Re: FEM library?

2017-02-22 Thread XavierAP via Digitalmars-d-learn
@Nicholas yes such a FEM library to be developed would heavily depend on Mir. Ilya Yaroshenko pointed me to it in another thread. I didn't know about DlangScience, thanks. Looks like there is some overlap? @Dukc thanks! Whenever in the future I'm developing for a library project or

FEM library?

2017-02-21 Thread XavierAP via Digitalmars-d-learn
Is there any D library for FEM (Finite Element Method, see Wikipedia) solving, meshing, etc... already existing somewhere? I'm asking because I'm considering making something in that field as a personal learning project. Depending on what can be found I can jump at some point to use a serious

multi-dimensional arrays, not arrays of arrays

2017-02-18 Thread XavierAP via Digitalmars-d-learn
Does D provide anything like this? Otherwise, was this ever considered and were reasons found not to have it? I mean at least in C# (not talking about C/C++ at all) you can declare two kind of multi-dimensional arrays: T[][][] or T[,,]. The first is the same as the D ones, array of arrays

Re: multi-dimensional arrays, not arrays of arrays

2017-02-18 Thread XavierAP via Digitalmars-d-learn
Nice, thanks! Will check it out

Recommend: IDE and GUI library

2017-02-24 Thread XavierAP via Digitalmars-d-learn
Hi I've looked at wiki.dlang.org/IDEs, and I see that Visual D is linked from dlang.org/download.html. Still I was looking for personal opinions and experiences beyond hard specs, I wonder if one of the IDEs is already dominant at least for each OS for any good reason. My requirements are

Re: Recommend: IDE and GUI library

2017-02-25 Thread XavierAP via Digitalmars-d-learn
On Saturday, 25 February 2017 at 20:03:17 UTC, Jacob Carlborg wrote: There's no de factor library for creating GUIs in D. If you want a native look and feel, DWT is a good option. If you want the application to look the same on all platforms, there might be other better suited alternatives.

Re: Recommend: IDE and GUI library

2017-03-01 Thread XavierAP via Digitalmars-d-learn
On Wednesday, 1 March 2017 at 20:00:32 UTC, thedeemon wrote: If you're building your app with VisualD (as opposed to invoking dub externally), make sure you've set up import paths in project settings properly. Thanks. With dub everything works straight forward. I just call it blindly since

Re: Recommend: IDE and GUI library

2017-03-01 Thread XavierAP via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 06:16:08 UTC, thedeemon wrote: For me Visual-D served well for years, and for GUI on Windows I've used DFL successfully (quite nice lib, very WinForms-like, with a visual editor) and now mostly use DLangUI (on both Windows and Linux). I'm trying now DlangUI on

Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-03-01 Thread XavierAP via Digitalmars-d-learn
On Wednesday, 1 March 2017 at 09:19:53 UTC, Christian Köstlin wrote: On 01/03/2017 00:09, Joseph Rushton Wakeling wrote: if (!__ctfe) assert(false); ... might be the best option. That shouldn't be compiled out even in -release builds. thats a nice idea! is this happening because of

Re: How to continue after the book?

2017-03-28 Thread XavierAP via Digitalmars-d-learn
On Tuesday, 28 March 2017 at 07:27:31 UTC, I Lindström wrote: I do have a need for which I've been trying out a few languages and D seems by far the best for me. Should I just start doing that project and learn as I go by googling and asking here, or are there some other things you did

Re: really why module declarations?

2017-03-26 Thread XavierAP via Digitalmars-d-learn
On Sunday, 26 March 2017 at 20:58:24 UTC, Adam D. Ruppe wrote: Module declarations are only optional in the most trivial case that is rarely useful in real world code. I recommend you ALWAYS use them (and always put a ddoc comment on them!), and moreover that you avoid top name modules (use

how to define my own traits

2017-03-26 Thread XavierAP via Digitalmars-d-learn
I've looked into Phobos to emulate it when defining my own trait template, and when I see this: module std.range.primitives; // ... template isInputRange(R) { enum bool isInputRange = is(typeof( (inout int = 0) { R r = R.init; // can define a range object if

really why module declarations?

2017-03-26 Thread XavierAP via Digitalmars-d-learn
I've perused both the spec[1] and Andrei's book, and I the idea I get is that module declarations are optional, recommended only in case of file names not being valid D names. But in the community (and Phobos) I see it's strongly recommended and used throughout. What's the reason? If the

Re: how to define my own traits

2017-03-27 Thread XavierAP via Digitalmars-d-learn
On Monday, 27 March 2017 at 00:49:14 UTC, Moritz Maxeiner wrote: Have you tried it without the dummy parameter on the example given in the bug report [2]? I see, thanks for finding it! Looks a bit hacky but I can live with it. Indeed if I remove the argument from Phobos, Martin's example

Re: Why is this legal?

2017-03-30 Thread XavierAP via Digitalmars-d-learn
On Wednesday, 29 March 2017 at 09:50:10 UTC, abad wrote: Is this on purpose and what's the rationale? In Andrei's book, chapter 6.9.1 "the non virtual interface (NVI) idiom" answers your question. It cites this article by Herb Sutter as the originator of the idea:

Re: how to define my own traits

2017-03-27 Thread XavierAP via Digitalmars-d-learn
On Monday, 27 March 2017 at 16:28:13 UTC, Gary Willoughby wrote: Even Andrei was baffled: http://forum.dlang.org/thread/nepm2k$311l$1...@digitalmars.com I see... And Walter went further and reported it as a DMD bug (still open clearly). It's what I mean. This strange behavior is more

Re: recommend Git GUI client for Linux?

2017-03-25 Thread XavierAP via Digitalmars-d-learn
On Thursday, 2 March 2017 at 06:16:09 UTC, Patrick Schluter wrote: Here [1] is the official git page listing all GUI clients for different plartforms. I use GitExtensions[2] and I like it a lot. It works very well and all the complicated stuff can be done from the GUI interface and also from

Re: Error: out of memory

2017-03-19 Thread XavierAP via Digitalmars-d-learn
On Sunday, 19 March 2017 at 20:50:50 UTC, Gand Alf wrote: just use DMD with the -m64 parameter ;) then you should get a x64 DMD No, at least afaik, then you tell DMD to make a x64 exe, but DMD itself (this particular Windows version) is still a 32-bit exe.

Re: Sorting Assosiative Arrays and Finding Largest Common Substring

2017-03-16 Thread XavierAP via Digitalmars-d-learn
On Thursday, 16 March 2017 at 16:02:13 UTC, helxi wrote: 1. .length is of type ulong Either use auto or if needed size_t. As Thedeemon says this is an alias of ulong on 64-bit and uint on 32. https://dlang.org/spec/hash-map.html

Re: first try

2017-03-17 Thread XavierAP via Digitalmars-d-learn
On Friday, 17 March 2017 at 00:35:32 UTC, Philip Miess wrote: https://gitlab.com/pmiess/101gamesDlangComputerGames/blob/master/ aceyducy.d You don't need string literals to be verbatim (r"") in order to insert newlines as in the code (without escape sequences). All string literals behave

GitHub detects .d source as Makefile?

2017-03-17 Thread XavierAP via Digitalmars-d-learn
So I have put my first code even on GitHub (comments welcome :)) and GitHub seems to detect the wrong language, even if I'm not familiar with this GH feature. https://github.com/XavierAP/etc/tree/master/heatsim The repository itself ("etc") is flagged as been written in Makefile? Right now I

Re: Error: out of memory

2017-03-18 Thread XavierAP via Digitalmars-d-learn
On Saturday, 18 March 2017 at 20:39:20 UTC, StarGrazer wrote: about 2GB before it quites. It also only uses about 12% of cpu. I have 16 GB total memory and about that free. Surely dmd could do a better job? Any way to get it to do such a thing like set the maximum amount of memory it can

Re: Phobos function to check if files are identical?

2017-03-14 Thread XavierAP via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 18:26:52 UTC, flamencofantasy wrote: import std.mmfile; auto f1 = new MmFile("file1"); auto f2 = new MmFile("file2"); return f1[] == f2[]; Nice! I don't have experience with memory-mapped files. What are the pros and cons?

Re: GitHub detects .d source as Makefile?

2017-03-18 Thread XavierAP via Digitalmars-d-learn
On Saturday, 18 March 2017 at 10:52:31 UTC, XavierAP wrote: Thanks! It seems I can also override the language detection in .gitattributes, and it is now fixed :) The majority language assigned to the whole repository is fixed, but alas syntax highlighting in heatsim.d is still wrong. Looks

Re: GitHub detects .d source as Makefile?

2017-03-18 Thread XavierAP via Digitalmars-d-learn
On Saturday, 18 March 2017 at 01:33:13 UTC, David Nadlinger wrote: The code GitHub uses to infer source file languages is open-source, and – fittingly – available on GitHub: https://github.com/github/linguist You should check the issues for reports of similar D-related problems, and if

Re: GitHub detects .d source as Makefile?

2017-03-20 Thread XavierAP via Digitalmars-d-learn
On Sunday, 19 March 2017 at 21:53:17 UTC, Seb wrote: FWIW this has been fixed by Martin last summer, but the people at GitHub aren't very responsive. The PR is still pending :/ More info: https://trello.com/c/g9PB3ISG/233-improve-d-language-recognition-on-github

Re: Use of "T"

2017-04-12 Thread XavierAP via Digitalmars-d-learn
On Wednesday, 12 April 2017 at 14:46:20 UTC, solidstate1991 wrote: Yes, templates. I've looked this up a bit, and I found it. I want to use it to use the dictionaries for different things than string<->int conversion. T is just the common name of a (type) parameter, mostly whenever the

Re: Can we disallow appending integer to string?

2017-04-21 Thread XavierAP via Digitalmars-d-learn
On Wednesday, 19 April 2017 at 14:50:38 UTC, Stanislav Blinov wrote: On Wednesday, 19 April 2017 at 14:36:13 UTC, Nick Treleaven Why is it legal to append an integer? Because integrals implicitly convert to characters of same width (byte -> char, short -> wchar, int -> dchar). Huh... I

DMD requirements (VC runtime version) where?

2017-04-21 Thread XavierAP via Digitalmars-d-learn
Visual D has just added support for VS 2017 (kudos), whereas before I had to stick with 2015 at the latest. But DMD has an additional dependency on VS (for x64), and it is not documented, as far as I've been able to find, which versions. So I just tried, and now the DMD Windows installer

Re: DMD requirements (VC runtime version) where?

2017-04-21 Thread XavierAP via Digitalmars-d-learn
On Friday, 21 April 2017 at 11:37:07 UTC, Mike Parker wrote: sc.ini manually is the better option if you don't need or want the 2015 build tools. Thanks! Nevertheless I think it would be good that the supported version of VS is documented on the website of DMD, just like it is on

Re: multi-dimensional array whole slicing

2017-04-23 Thread XavierAP via Digitalmars-d-learn
On Sunday, 23 April 2017 at 09:06:35 UTC, Ali Çehreli wrote: It took me a while to convince myself that there is no bug here. The problem, as is obvious to others, ;) a whole slice of a whole slice is still the same slice. Ha, you're right, I hadn't realized. But I still have a problem.

function type parameter inference not working

2017-04-23 Thread XavierAP via Digitalmars-d-learn
It's not working for my case, while I see no special reason why it couldn't. Also I can't find specific inference rules at http://dlang.org/spec/function.html#function-templates Is it a problem that the types to be inferred are in turn also templated? Any workaround that can make inference

Re: function type parameter inference not working

2017-04-23 Thread XavierAP via Digitalmars-d-learn
On Sunday, 23 April 2017 at 19:40:39 UTC, ag0aep6g wrote: Please post self-contained code. When I fill the gaps you left, it works for me: Interesting, thanks a lot. I'll test and narrow down what's in my code preventing this from working (I can't really think of anything) and I'll report

multi-dimensional array whole slicing

2017-04-22 Thread XavierAP via Digitalmars-d-learn
I can do: int[3] arr = void; arr[] = 1; But apparently I can't do: int[3][4] arr = void; arr[][] = 1; What is the best way? What am I missing?

Re: multi-dimensional array whole slicing

2017-04-23 Thread XavierAP via Digitalmars-d-learn
On Saturday, 22 April 2017 at 22:25:58 UTC, kinke wrote: int[3][4] arr = void; (cast(int[]) arr)[] = 1; assert(arr[3][2] == 1); Thanks... I think I prefer to write two loops though :p I wish D built-in arrays supported [,] indexing notation like C# (or as you can do in D for custom types)

DMD default safety command line switch

2017-03-09 Thread XavierAP via Digitalmars-d-learn
Andrei's 2010 book states that the default safety level can be changed from @system to @safe by means of a -safe command line switch, in the case of the DMD compiler. Now I've tried it and it's not recognized. Was this feature remove on purpose? I could imagine that. The default safety keeps

@safe console input?

2017-03-09 Thread XavierAP via Digitalmars-d-learn
I was surprised by a compiler message saying that std.stdio.readln() (and specifically the overload without arguments) is not safe but @system. Actually I was using it only to pause execution until the user presses Enter. So how else could I do this within a @safe environment? And more

Re: DMD default safety command line switch

2017-03-09 Thread XavierAP via Digitalmars-d-learn
On Friday, 10 March 2017 at 01:13:26 UTC, XavierAP wrote: What behavior? Anyway my question is answered, thanks :) What behavior is a rhetorical question, meaning that I don't really want it to be answered 0;)

Re: DMD default safety command line switch

2017-03-09 Thread XavierAP via Digitalmars-d-learn
On Friday, 10 March 2017 at 01:17:57 UTC, Jack Stouffer wrote: On Friday, 10 March 2017 at 01:13:26 UTC, XavierAP wrote: On Friday, 10 March 2017 at 00:48:39 UTC, Jack Stouffer wrote: Don't know the history, but as recently as a week ago Andrei has argued against such behavior has balkanizing

can I overload operators as extension methods?

2017-03-09 Thread XavierAP via Digitalmars-d-learn
The same way as T.foo() is lowered to foo(T) if no such member is defined inside the type. It would allow me to extend 3rd party types with operator notation without wrapping them. After trying and reading the specification, looks like nuts, but just wanted to confirm. Thx

Re: @safe console input?

2017-03-09 Thread XavierAP via Digitalmars-d-learn
On Thursday, 9 March 2017 at 23:55:35 UTC, Adam D. Ruppe wrote: Just wrap it in a @trusted function. I knew this answer already of course ;) but I take it as implying that there is no other way. Actually I really wonder why std.stdio.readln() itself is not flagged @trusted. I wouldn't

Re: DMD default safety command line switch

2017-03-09 Thread XavierAP via Digitalmars-d-learn
On Friday, 10 March 2017 at 00:48:39 UTC, Jack Stouffer wrote: Don't know the history, but as recently as a week ago Andrei has argued against such behavior has balkanizing the community. What behavior? Anyway my question is answered, thanks :)

Re: Best memory management D idioms

2017-03-07 Thread XavierAP via Digitalmars-d-learn
On Tuesday, 7 March 2017 at 18:21:43 UTC, Eugene Wissner wrote: To avoid this from the beginning, it may be better to use allocators. You can use "make" and "dispose" from std.experimental.allocator the same way as New/Delete. Thanks! looking into it. Does std.experimental.allocator have a

Re: Can you fix this code to avoid using pointers?

2017-03-11 Thread XavierAP via Digitalmars-d-learn
On Saturday, 11 March 2017 at 19:15:59 UTC, H. S. Teoh wrote: What about just: foreach (const ref p; [in1, in2, in3, in4]) I would think there will be already one copy from the local parameter variables to the in situ array. Then from that one into the for each element it's ref'd

Re: Can you fix this code to avoid using pointers?

2017-03-11 Thread XavierAP via Digitalmars-d-learn
On Saturday, 11 March 2017 at 13:44:30 UTC, Satoshi wrote: void calc(in double[] array...) { foreach (x; array) { } } To do what I want it should be foreach(ref x; array) -- or const ref. But also I don't want to modify the function signature, certainly in this way. In another situation

Re: Can you fix this code to avoid using pointers?

2017-03-13 Thread XavierAP via Digitalmars-d-learn
On Monday, 13 March 2017 at 14:47:20 UTC, H. S. Teoh wrote: On Sat, Mar 11, 2017 at 08:07:39PM +, XavierAP via Digitalmars-d-learn wrote: [...] But I still like the version with pointers ;) There's nothing wrong with using pointers in D. The fact that D alleviates most cases

Phobos function to check if files are identical?

2017-03-13 Thread XavierAP via Digitalmars-d-learn
It's not easy to do by hand of course, but I was wondering if there was one simple function taking two file names and just returning a bool or something like that. I haven't found it in std.file. If such a function doesn't exist in Phobos but there's a good implementation in some other

Re: Best ways to declare associative arrays

2017-03-12 Thread XavierAP via Digitalmars-d-learn
On Sunday, 12 March 2017 at 07:58:40 UTC, helxi wrote: string[string] change(ref string[string] arg_array){ //.. arg_array["first"] = strip(readln()); //.. arg_array["second"] = strip(readln()); //.. return def; } Nicholas clarified why your

Re: Code style for property

2017-03-12 Thread XavierAP via Digitalmars-d-learn
On Sunday, 12 March 2017 at 11:15:04 UTC, Nicholas Wilson wrote: On Sunday, 12 March 2017 at 10:47:35 UTC, Andrey wrote: And I want make access to read x, y and bar. Probably I should add prefix for private members, that is a question: what prefix should I use? Now I use prefix p_ (from the

Can you fix this code to avoid using pointers?

2017-03-11 Thread XavierAP via Digitalmars-d-learn
I do not really think it's a bad solution, to check several scalar arguments that must obey the same condition; just wondering if you have better ideas. Try to avoid modifying the function's signature and defining custom types, unless you have a really terrific idea. void calc(double in1,

Re: Can you fix this code to avoid using pointers?

2017-03-11 Thread XavierAP via Digitalmars-d-learn
Oh... please forget it What a terrible example :p I forgot why I was using pointers at all... I must have had a reason to write this in the past ???

Re: Can you fix this code to avoid using pointers?

2017-03-11 Thread XavierAP via Digitalmars-d-learn
On Saturday, 11 March 2017 at 12:35:42 UTC, XavierAP wrote: I do not really think it's a bad solution, to check several scalar arguments that must obey the same condition; just wondering if you have better ideas. Try to avoid modifying the function's signature and defining custom types, unless

Re: Declaring interfaces with a constructor

2017-03-13 Thread XavierAP via Digitalmars-d-learn
On Monday, 13 March 2017 at 02:15:21 UTC, David Zhang wrote: What it says on the tin. Is there a way to create interfaces with a constructor or must I use an abstract class. What do you want to do in your constructor? I can't think of anything that wouldn't change some state, either of the

Re: Phobos function to check if files are identical?

2017-03-13 Thread XavierAP via Digitalmars-d-learn
On Monday, 13 March 2017 at 17:47:09 UTC, H. S. Teoh wrote: Binary comparison is easy. Just read the files by fixed-sized chunks and compare them. Follow up question... What is the best @safe way? Since File.byChunk() is @system. Just out of curiosity, I would rather use it and flag my

Re: code folding

2017-03-13 Thread XavierAP via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 00:38:12 UTC, Vladimir Panteleev wrote: If you have enough declarations in one file that they call for code folding, it may be better to move them to a separate module. Public imports and aliases allow doing this without breaking any code. [...] Generally

Re: Phobos function to check if files are identical?

2017-03-14 Thread XavierAP via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 08:12:16 UTC, Andrea Fontana wrote: First I would check if the files have different size or if they are the same file (same path, symlink, etc). Good idea. Good reason to have it in std.file. There might also be platform dependent shortcuts?

Re: code folding

2017-03-13 Thread XavierAP via Digitalmars-d-learn
On Monday, 13 March 2017 at 17:29:41 UTC, Inquie wrote: I have been using static if(true) { ... junk } Indeed #region is part of the C# specification, even if it has no effect on the code. (The specification does not say anything about folding/collapsing, just about "marking sections

Re: Phobos function to check if files are identical?

2017-03-13 Thread XavierAP via Digitalmars-d-learn
On Monday, 13 March 2017 at 17:47:09 UTC, H. S. Teoh wrote: Why it is not easy to do by hand? Sorry typo, I had intended to type "I know it is easy"

Re: Best memory management D idioms

2017-03-06 Thread XavierAP via Digitalmars-d-learn
On Monday, 6 March 2017 at 08:26:53 UTC, Eugene Wissner wrote: The memory management in D is becoming a mess. I am aware this is a hot topic, hence the opening joke. But I just want to learn what toolboxes are currently available, not really discuss how adequate they are, or how often GC is

Re: How to compile against GitHub fork of Phobos?

2017-03-07 Thread XavierAP via Digitalmars-d-learn
On Tuesday, 7 March 2017 at 01:14:28 UTC, Q. Schroll wrote: I have a fork of the standard-library in the folder "phobos". DMD looking for the built-in phobos is specified in the configuration file (sc.ini on Windows, dmd.conf on Linux), not hardcoded. You may want to remove it from there.

Re: Best memory management D idioms

2017-03-07 Thread XavierAP via Digitalmars-d-learn
On Tuesday, 7 March 2017 at 16:51:23 UTC, Kagamin wrote: There's nothing like that of C++. Don't you think New/Delete from dlib.core.memory fills the bill? for C++ style manual dynamic memory management? It looks quite nice to me, being no more than a simple malloc wrapper with

Best memory management D idioms

2017-03-05 Thread XavierAP via Digitalmars-d-learn
I was going to name this thread "SEX!!" but then I thought "best memory management" would get me more reads ;) Anyway now that I have your attention... What I want to learn (not debate) is the currently available types, idioms etc. whenever one wants deterministic memory management. Please do

Re: rdmd with a file with no extension

2017-03-01 Thread XavierAP via Digitalmars-d-learn
On Wednesday, 1 March 2017 at 16:06:20 UTC, Colin wrote: When running a small D program through rdmd, it seems the file needs a .d extension to work. It looks like the file extension is enforced: https://dlang.org/dmd-windows.html#switches Looks like a feature rather than a bug... At the

DUB specify version identifier on command line?

2017-03-07 Thread XavierAP via Digitalmars-d-learn
I'm talking about the conditional compilation keyword "version", not about version strings. I've looked in DUB's help and reference [1][2] but can't seem to find how to solve my problem. On the command line it seems to be possible to specify debug identifiers, but not version identifiers. [3]

Re: Best memory management D idioms

2017-03-07 Thread XavierAP via Digitalmars-d-learn
On Tuesday, 7 March 2017 at 18:21:43 UTC, Eugene Wissner wrote: To avoid this from the beginning, it may be better to use allocators. You can use "make" and "dispose" from std.experimental.allocator the same way as New/Delete. OK I've been reading on std.experimental.allocator; it looks

Re: DUB specify version identifier on command line?

2017-03-08 Thread XavierAP via Digitalmars-d-learn
On Wednesday, 8 March 2017 at 02:15:00 UTC, Nicholas Wilson wrote: Setting version identifiers is done by the `-version=ident` command line flag (this is equivalent to `version = ident` at source level) . This should therefore be settable by the "dflags" dub configuration setting. The way I

Re: function type parameter inference not working

2017-04-25 Thread XavierAP via Digitalmars-d-learn
On Sunday, 23 April 2017 at 19:40:39 UTC, ag0aep6g wrote: Please post self-contained code. When I fill the gaps you left, it works for me: Found it! It stops working (DMD v2.073.0 for Windows) if it has to infer the type of a temporary local variable -- constructed in place of the

Re: function type parameter inference not working

2017-04-25 Thread XavierAP via Digitalmars-d-learn
On Tuesday, 25 April 2017 at 19:57:30 UTC, Ali Çehreli wrote: This is an intentional limitation of D. It's not possible to bind rvalues (temporaries) to reference parameters. The best option here is 'auto ref': Aha I had forgotten about the ref (obviously, otherwise I wouldn't have passed

Re: multi-dimensional array whole slicing

2017-04-25 Thread XavierAP via Digitalmars-d-learn
On Tuesday, 25 April 2017 at 20:46:24 UTC, Ali Çehreli wrote: I think it's still consistent because the element type is not int in the case of multi-dimensional arrays. [...] int[3][4] b; b[] = [1, 1, 1]; It is consistent, I just miss the possibility to more easily initialize

Re: New programming paradigm

2017-09-07 Thread XavierAP via Digitalmars-d-learn
On Wednesday, 6 September 2017 at 23:20:41 UTC, EntangledQuanta wrote: So, no body thinks this is a useful idea or is it that no one understands what I'm talking about? I think it may be a good use, although I haven't invested so much time looking into your particular application. It looks

Re: Auto keyword and when to use it

2018-08-22 Thread XavierAP via Digitalmars-d-learn
On Tuesday, 21 August 2018 at 21:37:00 UTC, QueenSvetlana wrote: I had a misunderstanding about the keyword auto because I wrongfully believed that it made the code like Python Exactly, you are thinking still like D is Python or also dynamically typed. :) You will get when compiling errors

Re: Templated operator overloading

2018-08-22 Thread XavierAP via Digitalmars-d-learn
On Wednesday, 22 August 2018 at 12:36:39 UTC, Simen Kjærås wrote: Since both your opOpAssigns match equally, the compiler throws up. The solution is to add some sort of restriction: This doesn't happen apparently: the operator has a left and a right side, even if both types define the

Re: Templated operator overloading

2018-08-22 Thread XavierAP via Digitalmars-d-learn
On Wednesday, 22 August 2018 at 13:20:01 UTC, aliak wrote: "void opOpAssign(string op, T)(ref Tthis, const ref T x)" looks like the wrong signature for opOpAssign. Oh I'll put on my stupid hat now... I realize I had copy-pasted the wrong syntax from the global function attempt, but I swear

Templated operator overloading

2018-08-22 Thread XavierAP via Digitalmars-d-learn
I've been trying some things to template operator overloads. The reason is that I want very similar code for different types, but I can't use polymorphism, as they're structs rather than classes. Perhaps this choice is not as advantageous as I think, and I may change this design from structs

Nested template arguments

2018-08-22 Thread XavierAP via Digitalmars-d-learn
Why foo!bar!x is not understood as foo!(bar!x) but instead gives an error "multiple ! arguments are not allowed"? Precisely because multiple "!" can never belong to the same instantiation, why does the parser not understand without needing brackets that the rightmost

Re: Nested template arguments

2018-08-22 Thread XavierAP via Digitalmars-d-learn
On Wednesday, 22 August 2018 at 14:48:57 UTC, Alex wrote: Because it could be meant as the argument to some templates to the left. Like (foo!bar)!x Sure, it would be a coincidence, if both will work. However, templates are not something where you can simply imply the associative property,

Re: Auto keyword and when to use it

2018-08-21 Thread XavierAP via Digitalmars-d-learn
On Monday, 20 August 2018 at 17:52:17 UTC, QueenSvetlana wrote: So I can't declare class level variables with auto, correct? only local method variables? One difference between D's auto and C#'s var or C++'s auto is that the latter languages allow automatically typed declarations only for

Re: Doubt about this book: The D Programming Language

2018-12-19 Thread XavierAP via Digitalmars-d-learn
On Sunday, 16 December 2018 at 18:37:15 UTC, Marko wrote: On Amazon The D Programming Language has good reviews but it's 8 years old. So is this book still relevant today? Yes, I would recommend it. It is meant to be comprehensive but introductory, so many language or library changes since

Re: Poor regex performance?

2019-04-04 Thread XavierAP via Digitalmars-d-learn
On Thursday, 4 April 2019 at 09:53:06 UTC, Julian wrote: Relatedly, how can I add custom compiler flags to rdmd, in a D script? For example, -L-lpcre Configuration variable "DFLAGS". On Windows you can specify it in the sc.ini file. On Linux: https://dlang.org/dmd-linux.html

Re: What Does @ Mean?

2019-04-08 Thread XavierAP via Digitalmars-d-learn
On Monday, 8 April 2019 at 11:58:49 UTC, Ron Tarrant wrote: And while I'm asking, does an underscore have special meaning when used either at the beginning or end of a variable name? In D, @ is used as Adam has explained as a prefix indicating attributes (either user-defined ones or,

Re: Distinguish float and integer types from string

2019-03-11 Thread XavierAP via Digitalmars-d-learn
On Saturday, 9 March 2019 at 18:11:09 UTC, Jacob Shtokolov wrote: One of the task was to take a string from STDIN and detect its type. There were a few options: Float, Integer, string and "something else" (which, I think, doesn't have any sense under the scope of the task). Another

Re: Distinguish float and integer types from string

2019-03-11 Thread XavierAP via Digitalmars-d-learn
On Monday, 11 March 2019 at 15:03:39 UTC, XavierAP wrote: What compiler version are you using? I on the other hand was surprised that I needed the try-catch above, after having already checked isNumeric. The documentation claims that the conversion to int or long would truncate, but my

Re: Best practices of using const

2019-02-13 Thread XavierAP via Digitalmars-d-learn
On Wednesday, 13 February 2019 at 11:32:46 UTC, envoid wrote: Is there an article that explains best practices of using const in D? Chapter 8 of Andrei Alexandrescu's book The D Programming Language.

Return Value Optimization: specification, requirements?

2019-02-02 Thread XavierAP via Digitalmars-d-learn
I've heard here and there that D guarantees RVO, or is even specified to do so... Is it spelled out in the language specification or elsewhere? I haven't found it. Do you know the exact requirements for RVO or NRVO to be possible in theory, and to be guaranteed in practice in D? Does it

Re: static arrays at runtime with templates ?

2019-02-04 Thread XavierAP via Digitalmars-d-learn
On Monday, 4 February 2019 at 19:14:38 UTC, Emil wrote: Can std.array.staticArray build static arrays with size known only at run time ? Now that I am not overcome with enthousiasm it looks like it too needs to know the size. A static array's size must be known (or computed) at compile

Re: static arrays at runtime with templates ?

2019-02-04 Thread XavierAP via Digitalmars-d-learn
On Sunday, 3 February 2019 at 16:33:48 UTC, Emil wrote: Is this for real, static arrays at runtime without manually allocating memory ? Is this legitimate or should I expect problems ? Static arrays are always allocated at run-time. It's the size of the array that must be known at

Re: Subtyping of an enum

2019-04-15 Thread XavierAP via Digitalmars-d-learn
On Monday, 15 April 2019 at 08:39:24 UTC, Anton Fediushin wrote: Hello! I am currently trying to add a custom `toString` method Several remarks... First of all, strings can be compared (alphabetically) as well as integers, e.g. assert("foo" > "bar") Perhaps not your use case, but worth

Re: Subtyping of an enum

2019-04-15 Thread XavierAP via Digitalmars-d-learn
On Monday, 15 April 2019 at 10:34:42 UTC, Anton Fediushin wrote: On Monday, 15 April 2019 at 10:06:30 UTC, XavierAP wrote: You have defined your sub-typing the opposite way that you wanted it to work: every `Enum` is an `internal`, but the other way around an `internal` may not work as an

Re: Subtyping of an enum

2019-04-15 Thread XavierAP via Digitalmars-d-learn
On Monday, 15 April 2019 at 10:34:42 UTC, Anton Fediushin wrote: The problem here is that I want to keep methods that are related to an enum inside of this enum for purely aesthetic and organizational purposes. ... These global functions pollute global namespace. If you have defined

Re: Subtyping of an enum

2019-04-15 Thread XavierAP via Digitalmars-d-learn
On Monday, 15 April 2019 at 12:38:59 UTC, XavierAP wrote: More generally you insist on modules and namespaces to be different concepts, which they are (pointlessly) for C++, but not for D (purposely). Here I should say packages instead of modules... but the general argument stays. Anyway

Re: Are static variables available to other static variables?

2019-04-12 Thread XavierAP via Digitalmars-d-learn
On Friday, 12 April 2019 at 10:56:32 UTC, Jamie wrote: On Friday, 12 April 2019 at 10:49:19 UTC, Jamie wrote: I was trying to declare a static variable dependent on another static variable, but it didn't work. Are static variables not known to other static variables at compile time? void

Re: Are static variables available to other static variables?

2019-04-12 Thread XavierAP via Digitalmars-d-learn
On Friday, 12 April 2019 at 10:56:32 UTC, Jamie wrote: On Friday, 12 April 2019 at 10:49:19 UTC, Jamie wrote: I was trying to declare a static variable dependent on another static variable, but it didn't work. Are static variables not known to other static variables at compile time? void

Re: Does slicing have an effect?

2019-05-27 Thread XavierAP via Digitalmars-d-learn
On Tuesday, 21 May 2019 at 20:44:49 UTC, rikki cattermole wrote: On 22/05/2019 8:31 AM, Dennis wrote: Does slicing have an effect I'm not aware of, or is this a bug? It could have an effect if a was a struct/class via operator overloads. But in this case it should probably be a bug. It

Re: Proper desctructor for an class containing dynamic array of objects

2019-06-14 Thread XavierAP via Digitalmars-d-learn
On Friday, 14 June 2019 at 11:10:58 UTC, rumbu wrote: On Friday, 14 June 2019 at 07:52:24 UTC, Marco de Wild wrote: On Thursday, 13 June 2019 at 16:08:52 UTC, Mike wrote: Opposed to Java, D's member variables are static initialised. Is there any documentation about this? I find it unexpected.

Re: How does this template work?

2019-06-18 Thread XavierAP via Digitalmars-d-learn
On Sunday, 16 June 2019 at 15:11:29 UTC, Robert M. Münch wrote: How does the observerObject Template and function work? I'm struggling because both use the same name and how is the template parameter R deduced/where is it coming from? Looks like it's somehow implicitly deduced. Eponymous

DIP 1016 and const ref parameters

2019-06-19 Thread XavierAP via Digitalmars-d-learn
I often use a pattern of having const ref struct parameters (as in C++) but this doesn't work in the case of rvalues. The workaround of defining an overload that calls its own name is terrible. I understand there was a DIP 1016 by Manu asking for this case to work. As far as I can tell, this

Re: DIP 1016 and const ref parameters

2019-06-19 Thread XavierAP via Digitalmars-d-learn
On Wednesday, 19 June 2019 at 12:55:09 UTC, Jonathan M Davis wrote: Even in C++, using const ref is not as good a practice as it once was, because they added move constructors, finally making object moveable. The result is that in many cases, it's actually more efficient to just copy values

Re: The problem with the conversion.

2019-06-19 Thread XavierAP via Digitalmars-d-learn
On Wednesday, 19 June 2019 at 14:58:44 UTC, drug wrote: 19.06.2019 17:52, Den_d_y пишет: void load (const (char *) path) {     SDL_Surface ab = SDL_LoadBMP (path);     a = SDL_CreateTextureFromSurface (ab);     SDL_FreeSurface (ab); } try the following: ``` void load (string path) {

Re: DIP 1016 and const ref parameters

2019-06-19 Thread XavierAP via Digitalmars-d-learn
Hmmm I know about move semantics, and C++11 etc. I just don't know how related all that is to my original question. :) On Wednesday, 19 June 2019 at 19:25:59 UTC, Jonathan M Davis wrote: though if I understand correctly with RVO, it may just place the return value outside of the function in

Re: Is it possible to escape a reserved keyword in Import/module?

2019-06-19 Thread XavierAP via Digitalmars-d-learn
On Wednesday, 19 June 2019 at 18:56:57 UTC, BoQsc wrote: I would like to make sure that my modules do not interfere with d lang. Is there any way to escape reserved words? The only reason C# allows this is for interop or code generation for other languages that use the same keyword. For

  1   2   >