Re: Is defining get/set methods for every field overkill?

2022-11-17 Thread via Digitalmars-d-learn
On Thursday, 17 November 2022 at 04:39:35 UTC, thebluepandabear wrote: I am creating a TUI library and I have a class with the following constant fields: ``` class Label : Renderable { const string text; const TextAlignment textAlignment; const Color color; this(Dimensions dime

Re: Is defining get/set methods for every field overkill?

2022-11-18 Thread via Digitalmars-d-learn
On Thursday, 17 November 2022 at 09:46:57 UTC, matheus wrote: Food for thought: https://yewtu.be/watch?v=_xLgr6Ng4qQ or https://www.youtube.com/embed/_xLgr6Ng4qQ Matheus. 'Food for thought'? Sure, if you're feeding that to your dog. Public fields in 'class' definitions rarely have place i

Re: Is defining get/set methods for every field overkill?

2022-11-18 Thread via Digitalmars-d-learn
On Friday, 18 November 2022 at 20:18:41 UTC, matheus wrote: On Friday, 18 November 2022 at 09:42:21 UTC, []() {}() wrote: ... I think you missed the point of that video very badly. By the way just a few points from that video: Around: 2:32 -> "Never ever put in an 'accessor' until it actual

Re: Is defining get/set methods for every field overkill?

2022-11-18 Thread via Digitalmars-d-learn
On Saturday, 19 November 2022 at 03:08:05 UTC, thebluepandabear wrote: It likely already does something, in that- >'it allows for change to occur without having to break the clients interface'. That too is the 'point' missing from that rant. With all due respect, I think your point is mostl

Re: Is defining get/set methods for every field overkill?

2022-11-18 Thread via Digitalmars-d-learn
On Thursday, 17 November 2022 at 09:52:11 UTC, Dukc wrote: .. D has far less need for getters/setters than Java or C++. The reason is [Uniform Function Call Syntax](https://ddili.org/ders/d.en/ufcs.html). This means that a member of a `struct` or `class` can start out as a normal field and be

Re: Is defining get/set methods for every field overkill?

2022-11-18 Thread via Digitalmars-d-learn
On Saturday, 19 November 2022 at 03:22:12 UTC, thebluepandabear wrote: On Saturday, 19 November 2022 at 03:19:53 UTC, []() {}() wrote: On Thursday, 17 November 2022 at 09:52:11 UTC, Dukc wrote: .. D has far less need for getters/setters than Java or C++. The reason is [Uniform Function Call S

Re: Is defining get/set methods for every field overkill?

2022-11-18 Thread via Digitalmars-d-learn
On Saturday, 19 November 2022 at 03:24:41 UTC, thebluepandabear wrote: I think because of uniform function call syntax, getters/setters are not needed even for production level code, in D of course. In Java, you do need them so your point holds true in that scenario, but in D I don't really s

Re: Is defining get/set methods for every field overkill?

2022-11-18 Thread via Digitalmars-d-learn
On Saturday, 19 November 2022 at 03:52:41 UTC, thebluepandabear wrote: On Saturday, 19 November 2022 at 03:39:18 UTC, []() {}() wrote: On Saturday, 19 November 2022 at 03:22:12 UTC, thebluepandabear wrote: On Saturday, 19 November 2022 at 03:19:53 UTC, []() {}() wrote: On Thursday, 17 November

Re: Is defining get/set methods for every field overkill?

2022-11-18 Thread via Digitalmars-d-learn
On Saturday, 19 November 2022 at 04:19:01 UTC, thebluepandabear wrote: oh. so i get it now. you have to refactor your class (change member variable names and also do it in all places where they are used througout the class. then add new methods, overloading them in this way and that way, all

Re: Is defining get/set methods for every field overkill?

2022-11-18 Thread via Digitalmars-d-learn
On Saturday, 19 November 2022 at 04:37:51 UTC, thebluepandabear wrote: Thankfully I only code in D as a hobby, so I don't need to use getters/setters! Thanks. well, in that case, you can throw out everything that programmers have learnt over many decades, and just to whatever you want in yo

Re: Is defining get/set methods for every field overkill?

2022-11-18 Thread via Digitalmars-d-learn
On Saturday, 19 November 2022 at 03:52:41 UTC, thebluepandabear wrote: ... . Honestly, it may not be a magic bullet, but still useful. This refactoring may be source compatible, but would it be binary compatible? i.e. you refactor your class, compile it as an updated version of your lib

Re: Is defining get/set methods for every field overkill?

2022-11-18 Thread via Digitalmars-d-learn
On Saturday, 19 November 2022 at 04:47:57 UTC, thebluepandabear wrote: https://learn.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/ms229042(v=vs.100) Thanks, I'll think about it more -- I am a noob so I may be wrong in what I am saying. Of course in C# this argument wouldn't

Re: Is defining get/set methods for every field overkill?

2022-11-19 Thread via Digitalmars-d-learn
On Saturday, 19 November 2022 at 04:47:57 UTC, thebluepandabear wrote: .. Of course in C# this argument wouldn't exist because you could just do `{ get; set; }`, and I really wish D had something similar 😂 If D had C#'s 'automatic' property syntax, it would as meaningless in D as it is in C#

Re: Is defining get/set methods for every field overkill?

2022-11-19 Thread via Digitalmars-d-learn
On Saturday, 19 November 2022 at 09:26:49 UTC, Andrey Zherikov wrote: On Saturday, 19 November 2022 at 09:12:26 UTC, thebluepandabear wrote: That's the point many people have given here which is not convincing him, even though it is quite great. I think we all know the answer here 😂 IMHO you

Re: Is defining get/set methods for every field overkill?

2022-11-19 Thread via Digitalmars-d-learn
On Saturday, 19 November 2022 at 09:51:09 UTC, []() {}() wrote: ... no. in C# it breaks ABI. that is why its not acceptable in my team. of course that's not the reason we don't use public member variables in classes. the reason we don't use them, is because (1) we always anticpiate chang

Re: Is defining get/set methods for every field overkill?

2022-11-19 Thread via Digitalmars-d-learn
On Saturday, 19 November 2022 at 19:59:20 UTC, Ali Çehreli wrote: On 11/19/22 01:43, [] () {} () wrote: > do it your way for the next 10 years, and > I bet you will eventually come to a different point of view ;-) Hm... I am responding without reading the rest of the thread so I don't know whe

Re: Is defining get/set methods for every field overkill?

2022-11-19 Thread via Digitalmars-d-learn
On Saturday, 19 November 2022 at 19:59:20 UTC, Ali Çehreli wrote: .. ... Ali The 10 years was mentioned, because it was what I learnt over that period (well, long before that actually). It wasn't mentioned to demonstrate that I have some superior knowledge. Object data needs to be protected.

Re: Is defining get/set methods for every field overkill?

2022-11-19 Thread via Digitalmars-d-learn
On Saturday, 19 November 2022 at 19:54:59 UTC, Ali Çehreli wrote: On 11/19/22 01:05, [] () {} () wrote: > All this because some programmer wanted to save a few key strokes, or > did not anticipate change, or did not anticipate the need to ensure data > is valid before assigning it, or returning

Re: Is defining get/set methods for every field overkill?

2022-11-19 Thread via Digitalmars-d-learn
On Thursday, 17 November 2022 at 04:39:35 UTC, thebluepandabear wrote: ... I am debating whether or not I should add getter methods to these properties. On one hand, it will inflate the codebase by a lot, on the other hand -- in other languages like Java it is a good practice: You really s

Re: Is defining get/set methods for every field overkill?

2022-11-19 Thread via Digitalmars-d-learn
On Saturday, 19 November 2022 at 23:05:30 UTC, thebluepandabear wrote: .. btw. Although this thread has well and truly exhausted it usefulness, the question you posed primarly relates to encapsulation, and as such, I think Scott Myers provided a reasonable answer to your question - more tha

Re: Is defining get/set methods for every field overkill?

2022-11-20 Thread via Digitalmars-d-learn
On Saturday, 19 November 2022 at 19:40:43 UTC, Ali Çehreli wrote: .. (I fully agree with the posted video.) ... Quoted from that video (the one that you agree with): "I don't ever think that private .. private is like just .. shouldn't even be used." "so I don't even use classes I just use

Re: Is defining get/set methods for every field overkill?

2022-11-20 Thread via Digitalmars-d-learn
On Sunday, 20 November 2022 at 12:23:39 UTC, Ali Çehreli wrote: On 11/20/22 00:31, [] () {} () wrote: > Quoted from that video (the one that you agree with): > > "I don't ever think that private .. private is like just .. shouldn't > even be used." > > "so I don't even use classes I just use str

Re: Is defining get/set methods for every field overkill?

2022-11-20 Thread via Digitalmars-d-learn
On Sunday, 20 November 2022 at 23:04:18 UTC, Siarhei Siamashka wrote: .. BTW, many software developers and also wikipedia actually agree with [] () {} (): https://en.wikipedia.org/wiki/Encapsulation_(computer_programming) and.. Autostar C++, Misra C++, Cert C++ ... I could go on and on. b

Re: Is defining get/set methods for every field overkill?

2022-11-20 Thread via Digitalmars-d-learn
On Sunday, 20 November 2022 at 12:23:39 UTC, Ali Çehreli wrote: Hm. 'private' is about access control. Encapsulation is something else. Ali "Clearly, encapsulation is not enough." https://www.infoworld.com/article/2075271/encapsulation-is-not-information-hiding.html

Re: Is defining get/set methods for every field overkill?

2022-11-20 Thread via Digitalmars-d-learn
On Monday, 21 November 2022 at 00:29:12 UTC, thebluepandabear wrote: .. not to mention, I'd be out of job if I stopped writing getters/setters ;-) I value your input in this discussion, you have brought some good points. Out of interest, what type of industry-level software are you creating

Re: Is defining get/set methods for every field overkill?

2022-11-20 Thread via Digitalmars-d-learn
On Sunday, 20 November 2022 at 12:23:39 UTC, Ali Çehreli wrote: .. Hm. 'private' is about access control. It's unfortunate that phrase ('private') is used, both traditionally, and now (and yes, even by me). A much better, clearer term, would be: 'interaction control', since that is wha

Re: Is defining get/set methods for every field overkill?

2022-11-21 Thread via Digitalmars-d-learn
On Monday, 21 November 2022 at 11:56:59 UTC, Ali Çehreli wrote: .. You took the question as whether to define them for class hierarchies, safety-critical systems, etc. Ali Or even in a very, very simple counter class: public synchronized class Counter { static import core.atomic;

Re: Is defining get/set methods for every field overkill?

2022-11-21 Thread via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 00:46:34 UTC, Siarhei Siamashka wrote: .. The `counter` member variable isn't really protected from rogue accesses (if these accesses are done by the code in the same source file) and this behavior differs from C++. module CounterTest; //@concrete public

Re: Is defining get/set methods for every field overkill?

2022-11-21 Thread via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 02:11:20 UTC, []() {}() wrote: maybe: @complete class insteadof: @concrete class

Re: Is defining get/set methods for every field overkill?

2022-11-21 Thread via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 02:16:16 UTC, []() {}() wrote: nevermind ;-) .. seems clear nobody wants something like this in D. https://forum.dlang.org/post/kbl20f$2np9$1...@digitalmars.com and... 20 years later ... .. .

Re: Is defining get/set methods for every field overkill?

2022-11-22 Thread via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 10:10:48 UTC, Sergey wrote: Based on this (not too old) post the idea remains the same and approved by Walter’s experience: https://dlang.org/blog/2018/11/06/lost-in-translation-encapsulation/ I saw some posts at forum about private-class-scope, but community o

Re: Is defining get/set methods for every field overkill?

2022-11-22 Thread via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 20:36:51 UTC, []() {}() wrote: From a software engineering perspective, what justification can their possibly be, for allowing (by default, and with no language mechanism to prevent it) any code in the same module as this class (including a tightly coupled, b

Re: Is defining get/set methods for every field overkill?

2022-11-22 Thread via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 21:00:58 UTC, []() {}() wrote: "Being able to declare a “friend” that is somewhere in some other file runs against notions of encapsulation." (This is the motivation for that article it seems). I completely disagree with the assertion. C++ Friend notion doe

Re: How often I should be using const? Is it useless/overrated?

2022-11-22 Thread via Digitalmars-d-learn
On Friday, 18 November 2022 at 11:51:42 UTC, thebluepandabear wrote: As a newcomer, I'd be interested in hearing everyones thoughts. Everyones thoughts? You sure about that ;-) anyho To Const or Not to Const? https://www.artima.com/articles/const-rtti-and-efficiency

Re: Is defining get/set methods for every field overkill?

2022-11-22 Thread via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 10:10:48 UTC, Sergey wrote: .. I saw some posts at forum about private-class-scope, but community of core-D is fine with module-unit approach I think. That's fair enough. I fully support 'majority rules' (if that's what's happening here). But it could limit t

Re: How often I should be using const? Is it useless/overrated?

2022-11-22 Thread via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 23:30:38 UTC, thebluepandabear wrote: On Tuesday, 22 November 2022 at 22:40:54 UTC, []() {}() wrote: On Friday, 18 November 2022 at 11:51:42 UTC, thebluepandabear wrote: As a newcomer, I'd be interested in hearing everyones thoughts. Everyones thoughts? You s

Re: Is defining get/set methods for every field overkill?

2022-11-23 Thread via Digitalmars-d-learn
On Wednesday, 23 November 2022 at 09:51:46 UTC, FeepingCreature wrote: The module is the capsule. D is simply not interested in building a capsule around a class. D does not let "anyone" pass through, it lets "anyone in the module" pass through, because the module is the wall. I think this is

Re: Is defining get/set methods for every field overkill?

2022-11-23 Thread via Digitalmars-d-learn
On Wednesday, 23 November 2022 at 13:24:37 UTC, Tejas wrote: On Wednesday, 23 November 2022 at 11:06:12 UTC, []() {}() wrote: On Wednesday, 23 November 2022 at 09:51:46 UTC, FeepingCreature wrote: Why then should a programming language insist that all other code in the module should be able

Re: Is defining get/set methods for every field overkill?

2022-11-23 Thread via Digitalmars-d-learn
On Wednesday, 23 November 2022 at 22:43:54 UTC, []() {}() wrote: My last post ;-) It seems far too many people conflate classes and oop. You can do oop without classes (whether you would want to is another question all together). You can also use class-types without doing oop. A class-ty

Re: Is defining get/set methods for every field overkill?

2022-11-23 Thread via Digitalmars-d-learn
On Thursday, 24 November 2022 at 02:00:15 UTC, Mike Parker wrote: On Wednesday, 23 November 2022 at 23:35:59 UTC, thebluepandabear wrote: Please stop, we get it... I'm not a moderator so I cannot enforce rules but there is NO need to continue this debate here. This software 'religiousness'

Re: Is defining get/set methods for every field overkill?

2022-11-23 Thread via Digitalmars-d-learn
On Thursday, 24 November 2022 at 05:41:11 UTC, Mike Parker wrote: On Thursday, 24 November 2022 at 03:49:16 UTC, []() {}() wrote: I broke a forum rule by critically analysing your blog? Wow. Criticize my blog posts all you want. Just stop please stop derailing threads. I'm going to delete

Integer without restrictions

2020-03-15 Thread ... via Digitalmars-d-learn
How to create an integer without restrictions of size? Do I need to create a new class or there is a type of integer that doesn't have any restrictions in size?

Re: Integer without restrictions

2020-03-15 Thread ... via Digitalmars-d-learn
On Sunday, 15 March 2020 at 19:03:54 UTC, Paul Backus wrote: On Sunday, 15 March 2020 at 19:02:00 UTC, ... wrote: How to create an integer without restrictions of size? Do I need to create a new class or there is a type of integer that doesn't have any restrictions in size? http://dpldocs.inf

Re: Funny issue with casting double to ulong

2017-07-03 Thread via Digitalmars-d-learn
On Monday, 3 July 2017 at 04:06:23 UTC, Saurabh Das wrote: On Monday, 3 July 2017 at 03:57:25 UTC, Basile B wrote: On Monday, 3 July 2017 at 03:50:14 UTC, Saurabh Das wrote: [...] 6.251 has no perfect double representation. It's real value is: 6.215099962483343551867E0 Hence whe

Re: C style 'static' functions

2017-07-19 Thread via Digitalmars-d-learn
On Wednesday, 19 July 2017 at 12:11:38 UTC, John Burton wrote: On Wednesday, 19 July 2017 at 12:05:09 UTC, Kagamin wrote: Try a newer compiler, this was fixed recently. Hmm it turns out this machine has 2.0.65 on which is fairly ancient. I'd not realized this machine had not been updated. S

Re: C style 'static' functions

2017-07-19 Thread via Digitalmars-d-learn
On Wednesday, 19 July 2017 at 15:28:50 UTC, Steven Schveighoffer wrote: On 7/19/17 8:16 AM, Petar Kirov [ZombineDev] wrote: On Wednesday, 19 July 2017 at 12:11:38 UTC, John Burton wrote: On Wednesday, 19 July 2017 at 12:05:09 UTC, Kagamin wrote: Try a newer compiler, this was fixed recently.

Re: C style 'static' functions

2017-07-19 Thread via Digitalmars-d-learn
On Wednesday, 19 July 2017 at 18:49:32 UTC, Johannes Pfau wrote: Can you explain why _object-level visibility_ would matter in this case? (I'm sure you have more experience with shared libraries than me, so correct me if I'm wrong) We can't do attribute inference for exported functions bec

Re: Why structs and classes instanciations are made differently ?

2017-07-24 Thread via Digitalmars-d-learn
On Mon, Jul 24, 2017 at 03:45:29PM +, Houdini via Digitalmars-d-learn wrote: > But in C++, we pass them by reference also to avoid copies (const &). Exactly... in C++ you basically always pass by reference, so D made that the default.

Re: Launch and obtain thread output during compile time

2017-08-13 Thread via Digitalmars-d-learn
On Sunday, 13 August 2017 at 07:37:15 UTC, data pulverizer wrote: Hi all, Is it possible to launch/spawn a thread/fibre or some other appropriate item and obtain an immutable/enum or some appropriate output at compile-time? For instance return an immutable(string) from the external thread to

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread via Digitalmars-d-learn
On Sunday, 13 August 2017 at 08:13:56 UTC, amfvcg wrote: On Sunday, 13 August 2017 at 08:00:53 UTC, Daniel Kozak wrote: my second version on ldc takes 380ms and c++ version on same compiler (clang), takes 350ms, so it seems to be almost same Ok, on ideone (ldc 1.1.0) it timeouts, on dpaste (

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread via Digitalmars-d-learn
On Sunday, 13 August 2017 at 08:29:30 UTC, Petar Kirov [ZombineDev] wrote: On Sunday, 13 August 2017 at 08:13:56 UTC, amfvcg wrote: On Sunday, 13 August 2017 at 08:00:53 UTC, Daniel Kozak wrote: my second version on ldc takes 380ms and c++ version on same compiler (clang), takes 350ms, so it se

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread via Digitalmars-d-learn
On Sunday, 13 August 2017 at 08:43:29 UTC, amfvcg wrote: On Sunday, 13 August 2017 at 08:33:53 UTC, Petar Kirov [ZombineDev] wrote: With Daniel's latest version ( http://forum.dlang.org/post/mailman.5963.1502612885.31550.digitalmars-d-le...@puremagic.com ) $ ldc2 -O3 --release sum_subranges2.

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread via Digitalmars-d-learn
On Sunday, 13 August 2017 at 09:41:39 UTC, Johan Engelen wrote: On Sunday, 13 August 2017 at 09:08:14 UTC, Petar Kirov [ZombineDev] wrote: [...] [...] Execution of sum_subranges is already O(1), because the calculation of the sum is delayed: the return type of the function is not `uint`

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread via Digitalmars-d-learn
On Sunday, 13 August 2017 at 09:56:44 UTC, Johan Engelen wrote: On Sunday, 13 August 2017 at 09:15:48 UTC, amfvcg wrote: Change the parameter for this array size to be taken from stdin and I assume that these optimizations will go away. This is paramount for all of the testing, examining, an

Re: Does anyone understand how to use "shared" types with concurrency send/receive functions?

2017-08-14 Thread via Digitalmars-d-learn
On Monday, 14 August 2017 at 03:59:48 UTC, Jonathan M Davis wrote: [snip] Now, the fact that the mutex objects don't handle shared correctly is another issue entirely. Having to cast away shared from mutexes is dumb, because you're obviously not going to be protecting them with a mutex, and t

Ranges: How to take N last of elements of range

2015-12-25 Thread via Digitalmars-d-learn
How to take N last of elements of range? I have tried the following example in my code, but it says that it deprecated. What is the other possible way? static struct LogerInfo { string func; int line; void write(T...)(T d

Re: Ranges: How to take N last of elements of range

2015-12-25 Thread via Digitalmars-d-learn
On Friday, 25 December 2015 at 20:06:04 UTC, drug wrote: 25.12.2015 17:13, Ur@nuz пишет: [...] You can do following http://dpaste.dzfl.pl/41c57f89a5a0 The reason of compile error is your using a range as a separator, change it to single symbol and it works. Also I used 'array' after 'tak

Re: Storing and Searching large text lists

2015-12-31 Thread via Digitalmars-d-learn
On 2016-01-01 13:22, Nicholas Wilson via Digitalmars-d-learn wrote: > On Friday, 1 January 2016 at 00:41:56 UTC, brian wrote: > >> I have a large list, B, of string items. For each item in that large list, I >> need to see if it is in the smaller list, A. I have b

Strange 'memset' error when using std.range.repeat and std.array.array

2016-01-04 Thread via Digitalmars-d-learn
Need some help)... Having the following chunk of code: string[] lines; ... if( firstIndentStyle == IndentStyle.space ) { lines ~= " ".repeat.take(newIndentCount).array; } else //Tabs { lines ~= "\t".repeat.take(newIndentCount).array; //This causes strange 'memset' error } This code fa

Re: Strange 'memset' error when using std.range.repeat and std.array.array

2016-01-04 Thread via Digitalmars-d-learn
Sorry, the actual code is: ... lines ~= ' '.repeat.take(newIndentCount).array; ...with character quotes. But it still fails with error described in stack trace in Gcx.bigAlloc()

Re: Strange 'memset' error when using std.range.repeat and std.array.array

2016-01-04 Thread via Digitalmars-d-learn
On Monday, 4 January 2016 at 12:00:32 UTC, tcak wrote: On Monday, 4 January 2016 at 10:50:17 UTC, Ur@nuz wrote: Sorry, the actual code is: ... lines ~= ' '.repeat.take(newIndentCount).array; ...with character quotes. But it still fails with error described in stack trace in Gcx.bigAlloc() W

Re: Strange 'memset' error when using std.range.repeat and std.array.array

2016-01-04 Thread via Digitalmars-d-learn
On Monday, 4 January 2016 at 14:25:30 UTC, Marc Schütz wrote: On Monday, 4 January 2016 at 12:20:09 UTC, Ur@nuz wrote: On Monday, 4 January 2016 at 12:00:32 UTC, tcak wrote: [...] Yes. It's Ubuntu 14. It works when it's in the separate example, but not working inside my project. The strange

Re: Possible to get Class of Interface at runtime

2016-01-23 Thread via Digitalmars-d-learn
On Saturday, 23 January 2016 at 21:03:21 UTC, Josh Phillips wrote: On Friday, 22 January 2016 at 23:44:34 UTC, Adam D. Ruppe wrote: There's a .classinfo property that works on Objects. If you have an interface, cast to Object first, and check for null, then get .classinfo off that. I tried t

Re: GC allocation

2016-04-21 Thread via Digitalmars-d-learn
I'm on mobile so I will be brief now and expand later On Thu, Apr 21, 2016 at 07:37:59PM +, QAston via Digitalmars-d-learn wrote: > Just like classes - when closure expression is executed. Heap closures are actually allocated on declaration. The compiler looks to see if it will ne

Re: Probably trivial Linux link problem that I've spent hours on.

2016-07-04 Thread via Digitalmars-d-learn
On Tue, Jul 05, 2016 at 03:32:25AM +, WhatMeWorry via Digitalmars-d-learn wrote: > $ sudo apt-get install sqlite3 I'm just guessing, but try install sqlite3-devel too

Re: On Concurrency

2014-04-20 Thread via Digitalmars-d-learn
On Friday, 18 April 2014 at 17:20:06 UTC, Nordlöw wrote: Could someone please give some references to thorough explainings on these latest concurrency mechanisms Coroutines is nothing more than explicit stack switching. Goroutines/fiber etc are abstractions that may be implemented using corou

Re: Is this a bug?

2014-04-29 Thread via Digitalmars-d-learn
On Tuesday, 29 April 2014 at 07:43:55 UTC, Andrey wrote: btw, short a,b,c; a = b + c; //error: cannot implicitly convert expression of type 'int' to 'short' Guys!! Tell me that I have an old slutty version of the compiler... No, it's correct. `b + c` is not guaranteed to fit into `a`, th

Re: const ref parameters and r-value references

2014-05-02 Thread via Digitalmars-d-learn
On Friday, 2 May 2014 at 08:17:09 UTC, Mark Isaacson wrote: I'm in the process of learning/practicing D and I noticed something that seems peculiar coming from a C++ background: If I compile and run: void fun(const ref int x) { //Stuff } unittest { fun(5); //Error! Does not compile } I g

Re: const ref parameters and r-value references

2014-05-04 Thread via Digitalmars-d-learn
On Friday, 2 May 2014 at 21:29:51 UTC, Mark Isaacson wrote: Auto ref parameters seem to be just what I need. Thanks! I'd still be curious if anyone has additional information regarding the rationale at play (I'm spoiled, reading TDPL and having each decision explained in text). I had the impr

Re: const ref parameters and r-value references

2014-05-04 Thread via Digitalmars-d-learn
On Sunday, 4 May 2014 at 11:15:59 UTC, Timon Gehr wrote: On 05/04/2014 12:58 PM, "Marc Schütz" " wrote: This means that you will still get a (bit-wise) copy if you pass in an r-value. But semantically, this is a move, not a copy, so it is potentially cheaper than a copy (if your type has an e

Re: Need help with movement from C to D

2014-05-06 Thread via Digitalmars-d-learn
On Tuesday, 6 May 2014 at 11:09:37 UTC, Andrey wrote: On Monday, 5 May 2014 at 17:55:37 UTC, Meta wrote: enum offsetof(T, string field) = mixin(type.stringof ~ "." ~ field ~ ".offsetof"); To ensure that a syntactically valid symbol is passed as the type. Interestingly, but this code does

Re: The writeln() function's args can't be ["一" ,"二"]?

2014-05-06 Thread via Digitalmars-d-learn
On Tuesday, 6 May 2014 at 13:35:57 UTC, FrankLike wrote: The problem is that you have a wide-character comma (,) there. This works: void main() { writeln(["一", "二"]); } No,I mean the execute result is error.That doesn't get the ["一", "二"],but get the ["涓C","浜?]. Why? Thank yo

Re: Need help with movement from C to D

2014-05-06 Thread via Digitalmars-d-learn
On Tuesday, 6 May 2014 at 14:25:01 UTC, Artur Skawina via Digitalmars-d-learn wrote: I'm not sure why you'd want to wrap the .offsetof expression in a template, but it can easily be done like this: enum offsetOf(alias A, string S) = mixin("A."~S~".offsetof")

sort struct of arrays

2014-05-09 Thread via Digitalmars-d-learn
If you have an array of structs, such as... struct Foo { int x; int y; } Foo[] foos; ...and you wanted to sort the foos then you'd do something like... foos.sort!(a.x < b.x), ..and, of course, both of the fields x and y get sorted together. If you ha

Re: sort struct of arrays

2014-05-09 Thread via Digitalmars-d-learn
On Friday, 9 May 2014 at 14:48:50 UTC, anonymous wrote: std.range.zip(fooX, fooY).sort!((a, b) => a[0] < b[0]); I wasn't sure if that's supposed to work. Turns out the documentation on zip [1] has this exact use case as an example. [1] http://dlang.org/phobos/std_range.html#zip Ha! Awesome! S

Re: Temporary silence output (stdout)

2014-05-11 Thread via Digitalmars-d-learn
On Saturday, 10 May 2014 at 20:24:50 UTC, MarisaLovesUsAll wrote: Hi! I sometimes got a useless messages in stdout from SDL_Image library, and I want to temporary silence it. How do I do? Are you sure it's stdout, not stderr? For the latter, you would need to redirect FD 2, not FD 1: ...

Re: Seg fault when calling C code

2014-05-16 Thread via Digitalmars-d-learn
On Friday, 16 May 2014 at 11:42:35 UTC, Kagamin wrote: For example, windows headers do use C++ &-references in function signatures and msdn provides code examples using that convention, the equivalent in D is ref. But that's extern(C++), not extern(C)...

Re: Problems with dmd Switches in Makefiles

2014-05-17 Thread via Digitalmars-d-learn
On Saturday, 17 May 2014 at 13:01:07 UTC, Tom Browder via Digitalmars-d-learn wrote: I know I'm supposed to use dub, but I'm not ready. I just found out I can't use dmd switches for file names variable in a GNU makefile, e.g., see this fragment %.o : %.d dmd -c $< -of

Re: Objects(from classes) at Compile time? no gc

2014-05-17 Thread via Digitalmars-d-learn
On Friday, 16 May 2014 at 22:48:08 UTC, Taylor Hillegeist wrote: Although, I don't know if it will allocate it during runtime as well. It will not. -Steve Does this work in GDC? Can't test in GDC, but it does work in LDC, and I see no reason why it shouldn't, because this functionality i

Re: Problems with dmd Switches in Makefiles

2014-05-18 Thread via Digitalmars-d-learn
For the compiler version, I've submitted a PR: https://github.com/D-Programming-Language/dmd/pull/3558

Re: Problems with dmd Switches in Makefiles

2014-05-19 Thread via Digitalmars-d-learn
On Sunday, 18 May 2014 at 16:15:53 UTC, Marc Schütz wrote: For the compiler version, I've submitted a PR: https://github.com/D-Programming-Language/dmd/pull/3558 Ok, the outcome is that a dedicated option is not seen as necessary. DMD already prints its version as the first line if you call

Re: Separate Piping of dmd stdout and stderr through ddemangle

2014-05-22 Thread via Digitalmars-d-learn
On Thursday, 22 May 2014 at 09:29:49 UTC, Nordlöw wrote: Is there a Bash way to pipe stdout and stderr *separately* through ddemangle? I'm aware of 2>&1 but this removes separation of stdout and stderr. You can use process substitution [1]: dmd ... 2> >( ddemangle >&2 ) (or leave out

Re: enums

2014-05-30 Thread via Digitalmars-d-learn
Some explanation how the seemingly different concepts "enumerated value" and "manifest constant" are actually related: Let's start with the "classical" enums as they're known from C/C++. They are used to create lists of symbolic names: enum Color { YELLOW, PINK, BLUE }; Internally, each

Re: dmd segfaults

2014-05-31 Thread via Digitalmars-d-learn
On Saturday, 31 May 2014 at 17:22:41 UTC, matovitch wrote: In fact it segfauls on any template parameter if it has the same name as the immutable member (at least it's coherent). Something as simple as : struct Foo(int i) { immutable int i = i; } void main() { Foo!5 foo; writeln(f

Re: delegate issue

2014-06-02 Thread via Digitalmars-d-learn
On Monday, 2 June 2014 at 06:56:54 UTC, captaindet wrote: hi, i stumbled upon something weird - it looks like a bug to me but maybe it is a "feature" that is unclear to me. so i know i can declare function and delegate pointers at module level. for function pointers, i can initialize with a

Re: Delegate, scope and associative array

2014-06-03 Thread via Digitalmars-d-learn
On Tuesday, 3 June 2014 at 13:30:13 UTC, Steven Schveighoffer wrote: There is a school of thought (to which I subscribe) that says you shouldn't allocate a separate closure for each loop iteration. Basically, a closure will only use the stack frame of the calling function, not any loop iterat

Re: Multiple alias this failed workaround...obscure error message

2014-06-11 Thread via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 18:07:44 UTC, matovitch wrote: source/app.d(5): Error: basic type expected, not cast source/app.d(5): Error: no identifier for declarator int source/app.d(5): Error: semicolon expected to close alias declaration source/app.d(5): Error: Declaration expected, not 'ca

Re: Cannot alias null

2014-06-13 Thread via Digitalmars-d-learn
On Thursday, 12 June 2014 at 21:07:47 UTC, Tom Browder via Digitalmars-d-learn wrote: What I was really trying to do was D'ify C expressions like this: typedef ((struct t*)0) blah; This doesn't compile for me with GCC, and I don't know what it's supposed to mean.

Re: Universal Construction Syntax for Pointers?

2014-06-14 Thread via Digitalmars-d-learn
On Saturday, 14 June 2014 at 08:09:12 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: Would auto i = (int*)(3); make sense? Does it work? No: Error: C style cast illegal, use cast(int*)3 And I don't think it should, because the heap allocation that you're probably expecting

Re: Why is stdin.byLine.writeln so slow?

2014-06-14 Thread via Digitalmars-d-learn
On Friday, 13 June 2014 at 22:12:01 UTC, Ali Çehreli wrote: On 06/13/2014 03:02 PM, monarch_dodra wrote: > No, it just receives a range, so it does range formating. eg: > "[" ~ Element ~ ", " ~ Element ... "]". It still looks like it could send the formatting characters as well as the elements

Re: Returning dynamic array from the function

2014-06-14 Thread via Digitalmars-d-learn
On Saturday, 14 June 2014 at 14:02:52 UTC, Marco Cosentino wrote: Hi, I'm new to D and stumbled upon this very interesting discussion. My question now is: can you provide an example of how to return a collection of homogeneous elements whose size is not known at compile time (for wich you would

Re: How to define and use a custom comparison function

2014-06-16 Thread via Digitalmars-d-learn
You can pass anything to the sort function that's callable, including an object: struct MyCompare { SortOrder order; int column; bool opCall(const ref DataRow lhs, const ref DataRow rhs) { return order == SortOrder.ASC ? lhs[column] < rhs

Re: D1: UTF8 char[] casting to wchar[] array cast misalignment ERROR

2014-06-17 Thread via Digitalmars-d-learn
On Tuesday, 17 June 2014 at 02:27:43 UTC, jicman wrote: Greetings! I have a bunch of files plain ASCII, UTF8 and UTF16 with and without BOM (Byte Order Mark). I had, "I thought", a nice way of figuring out what type of encoding the file was (ASCII, UTF8 or UTF16) when the BOM was missing, b

Re: Working on a library: request for code review

2014-06-17 Thread via Digitalmars-d-learn
On Monday, 16 June 2014 at 23:04:33 UTC, Rene Zwanenburg wrote: This one depends on taste, but these helpers can be eliminated by changing the Header definition a little. It's the same union / anonymous struct trick from the previous post, only this time with bitfields: http://dpaste.dzfl.pl/

Re: Working on a library: request for code review

2014-06-18 Thread via Digitalmars-d-learn
On Tuesday, 17 June 2014 at 18:35:34 UTC, Mike wrote: Thanks, will work on fixes tonight. The current method will not detect an error when the image type is not mapped but a color map is present. At least I assume that is not a valid TGA file? A non-mapped image may contain a color map ;-0

Re: Working on a library: request for code review

2014-06-19 Thread via Digitalmars-d-learn
On Wednesday, 18 June 2014 at 14:05:12 UTC, Rene Zwanenburg wrote: On Tuesday, 17 June 2014 at 13:07:33 UTC, Marc Schütz wrote: On Monday, 16 June 2014 at 23:04:33 UTC, Rene Zwanenburg wrote: This one depends on taste, but these helpers can be eliminated by changing the Header definition a litt

Re: how to correctly 'typedef' handle types

2014-06-20 Thread via Digitalmars-d-learn
On Friday, 20 June 2014 at 07:05:49 UTC, francesco cattoglio wrote: http://dlang.org/phobos/std_typecons.html#Typedef Take a look at it. Docs is scarce (pretty sure you will need to take a look around to find something) but it should just do what you need. The prerelease docs contain more in

opAssign() calls members' postblits?

2014-06-21 Thread via Digitalmars-d-learn
import std.stdio; struct A { this(this) { writeln("A.this(this)"); } B b1, b2; } struct B { this(this) { writeln("B.this(this)"); } } void main() { A a, b; a = b; } This outputs: B

Re: opAssign() calls members' postblits?

2014-06-22 Thread via Digitalmars-d-learn
On Saturday, 21 June 2014 at 20:03:26 UTC, Ali Çehreli wrote: > Now, http://dlang.org/struct.html#AssignOverload says: > > ref S opAssign(S s) > { Note that opAssign takes by-value. The post-blits that you see are due that copy. i.e. b in main is copied to the argument that opAssign

Re: Can't modify this

2014-06-30 Thread via Digitalmars-d-learn
On Saturday, 28 June 2014 at 21:39:35 UTC, Ary Borenszweig wrote: On 6/28/14, 6:21 PM, H. S. Teoh via Digitalmars-d-learn wrote: On Sat, Jun 28, 2014 at 05:40:19PM -0300, Ary Borenszweig via Digitalmars-d-learn wrote: This doesn't work: class Foo { this() { this = new Foo; } }

  1   2   3   4   5   6   7   8   9   10   >