Re: Sequence separation

2016-08-21 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Wednesday, 17 August 2016 at 19:38:22 UTC, Engine Machine wrote: Well, the is does work and that probably is the best solution. I don't mind the extra type at this point. Of course, a library solution for this type of stuff would be nice. I'd rather not have to even use a type but rather

Re: Rebind template

2016-08-21 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Saturday, 20 August 2016 at 22:18:57 UTC, Engine Machine wrote: On Saturday, 20 August 2016 at 22:11:40 UTC, Engine Machine wrote: Is there a way to rebind the arguments of a template? template foo(X) { // X is like A!(a,b,c) Y = Rebind!(X,d,e,f); // Y is like A!(d,e,f); }

__traits(getOverloads, Type, member) order of elements in tuple.

2016-08-22 Thread Alexandru Ermicioi via Digitalmars-d-learn
Good day. In current implementation of dmd/ldc/gdc, does this trait guarantee, that the order of elements returned in tuple, is same, in several calls of it on same Type and member? Also, is guaranteed that in future versions of dmd, the order of elements won't change?

Re: ddoc: Can I escape a colon?

2017-02-26 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Thursday, 23 February 2017 at 21:04:39 UTC, Nick Sabalausky (Abscissa) wrote: Suppose I want ddoc output to include this line: -- Note: Blah blabbety blah -- But the colon causes "Note" to be considered a section header. Is there a way to escape the ":" so that it's

Re: delegate passed in annotation struct cannot be invoked.

2016-12-30 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Thursday, 29 December 2016 at 21:29:47 UTC, Stefan Koch wrote: ldc accepts invalid code there. But it might be that dmd 2.071.2 did that as well. If so It will be fixed as soon as ldc updates the front-end version. Nope, tried with dmd v2.071.2 and it gives same error as v2.072.1. I think

code.dlang.org package readme.md

2017-01-03 Thread Alexandru Ermicioi via Digitalmars-d-learn
Hi all. How it is possible to show readme.md from github repository in code.dlang.org for a particular project? Thanks.

delegate passed in annotation struct cannot be invoked.

2016-12-29 Thread Alexandru Ermicioi via Digitalmars-d-learn
Given code below: import std.stdio; struct Annotation { public int delegate(int) dg; } void main() { import std.traits; __traits(getAttributes, Cls)[0].dg(20).writeln; } @Annotation(delegate int(int d) { return d; }) class Cls { void method() { } }

Re: delegate passed in annotation struct cannot be invoked.

2016-12-29 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Thursday, 29 December 2016 at 21:07:00 UTC, Stefan Koch wrote: It's a delegate and not function. Therefore it will get a frame-ptr regardless, without checking if it is needed or not, or if there is a frame to point to. Since there is no frame to point to you get the error. At least this is

ddoc and method overriding.

2017-08-12 Thread Alexandru Ermicioi via Digitalmars-d-learn
Hi all, Having a trivial example such as: ```D class Foo { /** * A documentation info **/ void fancy(); } class Moo { override void fancy(); } ``` Is there a way to tell ddoc to use Foo.fancy documentation block for overriding Moo.fancy method? Thx.

Function signature testing with is expression.

2017-12-17 Thread Alexandru Ermicioi via Digitalmars-d-learn
Hi, Have someone tried to test a function against a signature using is expression? Suppose: struct F { static void foo(T)(T i, int o) {} } enum bool check(T) = is(F.foo!T == void function(Z, int), Z); enum correct = check!int; Upon running it will return false,

Re: Function signature testing with is expression.

2017-12-17 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Sunday, 17 December 2017 at 16:19:00 UTC, ag0aep6g wrote: On Sunday, 17 December 2017 at 14:44:15 UTC, Alexandru Ermicioi wrote: Suppose: struct F { static void foo(T)(T i, int o) {} } enum bool check(T) = is(F.foo!T == void function(Z, int), Z); enum correct = check!int;

scope variable values assigned to non-scope this.placeholder

2018-08-06 Thread Alexandru Ermicioi via Digitalmars-d-learn
Hi Dlang community! I've been playing with dip1000 and scope storage class and stumbled upon a strange error that I can't to understand yet. Here is minimized version of code that generates the error: The link: https://run.dlang.io/is/rg2Odu -- import std.stdio;

Cannot dispose const array?

2018-08-08 Thread Alexandru Ermicioi via Digitalmars-d-learn
Hi Dlang community! I've stumbled on an interesting issue with allocators. It seems that we can't get disposed of arrays with const or immutable data. Consider example below: Link: https://run.dlang.io/is/frnQI8 import std.stdio; import std.range; import

template alias argument accepts only class/interface types.

2019-02-23 Thread Alexandru Ermicioi via Digitalmars-d-learn
Perhaps I missed somewhere, but it seems that you can pass only classes or interfaces to alias argument of a template. Trying to pass another type (such as int, int[]) yields an error. Example of issue: void test(alias T)(int o) { import std.stdio;

Converting stringized array to dstring[]

2019-02-24 Thread Alexandru Ermicioi via Digitalmars-d-learn
Hi everyone, I've stumbled on another possible bug: - import std.stdio; import std.conv; void main() { "[ \"test\" ]".to!(dstring[]).writeln; } - It gives following error: - /dlang/dmd/linux/bin64/../../src/phobos/std/conv.d(222): Error:

Re: Alternative to C++ macro in D

2019-11-03 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Sunday, 3 November 2019 at 17:02:30 UTC, Vinod K Chandran wrote: On Sunday, 3 November 2019 at 16:55:36 UTC, Vinod K Chandran wrote: Hi all, I can do this in C++. #include using namespace std ; #define end }; #define log(x) cout << x << endl #define wait std::cin.get() int main() {

Re: Alternative to C++ macro in D

2019-11-03 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Sunday, 3 November 2019 at 16:55:36 UTC, Vinod K Chandran wrote: Hi all, I can do this in C++. #include using namespace std ; #define end }; #define log(x) cout << x << endl #define wait std::cin.get() int main() { log("Trying to avoid the visual clutter aused by closing curly

Re: Translating Java into D

2019-11-16 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Friday, 15 November 2019 at 03:29:16 UTC, Heromyth wrote: On Thursday, 14 November 2019 at 19:50:22 UTC, NonNull wrote: Greetings, Java seems to be almost a subset of D in various ways. No, it's not exactly right. Java is more powerful than D as for a language. Many things that Java can do

Re: equivalent of typeid(Class).name at compile-time

2019-11-22 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Thursday, 21 November 2019 at 20:48:03 UTC, Adam D. Ruppe wrote: On Thursday, 21 November 2019 at 20:45:16 UTC, Steven Schveighoffer wrote: To clarify, I need the compile time string that will match typeid(instance).name, so I can match the derived type. You have to make sure that the

Re: Call method if declared only

2020-03-01 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Friday, 28 February 2020 at 06:12:37 UTC, Виталий Фадеев wrote: How to implement ? I would go for a template mixin that implements send operation in each subclass. Sine template mixin's content is declared in scope of declaration not template's module, the code inside it is aware of

Re: What type does byGrapheme() return?

2019-12-30 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Friday, 27 December 2019 at 17:26:58 UTC, Robert M. Münch wrote: ... There are set of range interfaces that can be used to mask range type. Check for https://dlang.org/library/std/range/interfaces/input_range.html for starting point, and for

Re: How create a function that receive a function and run it in another threading?

2019-12-30 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Friday, 27 December 2019 at 07:06:52 UTC, mipri wrote: On Friday, 27 December 2019 at 06:08:16 UTC, Marcone wrote: import std; import core.thread; auto threading(lazy void fun){ return task!fun().executeInNewThread(); } void main(){ threading(writeln("Hello World!")); } I want

Wrong selection of opEquals for objects.

2020-08-28 Thread Alexandru Ermicioi via Digitalmars-d-learn
Hi everyone, there is https://issues.dlang.org/show_bug.cgi?id=21180 bug, anyone knows how to avoid it? Test case: - import std; class Silly { bool opEquals(const Silly silly) const @safe { return silly is this; } alias opEquals = Object.opEquals; } bool

Re: Wrong selection of opEquals for objects.

2020-08-28 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Friday, 28 August 2020 at 08:16:01 UTC, Alexandru Ermicioi wrote: Hi everyone, Would be glad at least to pointers, where in dmd is logic for operator overloading happens, as well as for overloading rules, so I could fix it myself, if no-one is able to pick up it.

Re: Wrong selection of opEquals for objects.

2020-08-28 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Friday, 28 August 2020 at 10:28:07 UTC, Simen Kjærås wrote: What you'll need to do is mark every function that does compare two class objects with == as @trusted or @system. No that is not a solution at all, in template code that requires safety. You basically will have to sacrifice

Re: Wrong selection of opEquals for objects.

2020-08-28 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Friday, 28 August 2020 at 12:29:20 UTC, Simen Kjærås wrote: Seems that these methods should be rooted out from Object, and placed in respective interfaces like: - interface Equatable(T) { bool opEquals(T value); } - Then it would be a lot more simple. People who want

Re: Wrong selection of opEquals for objects.

2020-08-28 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Friday, 28 August 2020 at 10:42:09 UTC, Alexandru Ermicioi wrote: ... Also, why it is limited to just objects? It seems that this function enforces symmetry between two objects. What about rest of the possible types, such as structs, unions?

Re: cloning array

2021-06-03 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Wednesday, 2 June 2021 at 15:32:38 UTC, Sean wrote: ... You can implement deep copy using template recursion: import std; T[] rdup(T : U[], U)(T[] duped) { return duped.map!(arr => arr.rdup).array; } T[] rdup(T)(T[] duped) { return duped.dup; }

Re: how much "real-life" code can be marked @safe ?

2021-07-02 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Friday, 2 July 2021 at 00:26:52 UTC, someone wrote: ... just wondering: ... Imho, if you want all of the app to be safe, and you cannot avoid unsafe code, then there are two choices: 1. Mark the method doing unsafe stuff as @trusted, or pieces of code which are unsafe with trusted lambda

Re: Printing Tuple!(...)[] using for loop?

2021-07-02 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Friday, 2 July 2021 at 04:21:24 UTC, Kirill wrote: ... 1. use static foreach for tuple loop. 2. start column and end column should be known at compile time. Either make them immutable, or as enum constant, or pass them as an template argument. Tuple is basically a wrapper over built in

Re: how much "real-life" code can be marked @safe ?

2021-07-03 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Friday, 2 July 2021 at 22:08:31 UTC, tsbockman wrote: (Responding out of order:) On Friday, 2 July 2021 at 00:26:52 UTC, someone wrote: But when you start attempting to declare @safe chunks of code that actually DO things ... well, it seems end-of-the-story. If you find yourself unable to

Re: Error: function `...` without `this` cannot be `const`

2021-06-30 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Wednesday, 30 June 2021 at 20:12:29 UTC, H. S. Teoh wrote: On Wed, Jun 30, 2021 at 07:40:40PM +, someone via Digitalmars-d-learn wrote: [...] @property int data() { return m_data; } // read property [...] string something() @property { return this.whatever; } [...] Now I am not

Re: Error: function `...` without `this` cannot be `const`

2021-06-30 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Wednesday, 30 June 2021 at 17:47:05 UTC, someone wrote: ... That is because const/immutable/shared are being applied on the object hence 'this' variable inside function body if function is a member of a struct or class. It doesn't make sense to have a const modifier on a simple function.

Re: how much "real-life" code can be marked @safe ?

2021-07-04 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Saturday, 3 July 2021 at 20:09:56 UTC, tsbockman wrote: On Saturday, 3 July 2021 at 16:06:33 UTC, Alexandru Ermicioi wrote: 3. An edge case. Ex: You need to mutate some data and then assume it is immutable in a constructor. Can you give a valid example where that is necessary? The main

Re: Drawbacks of exceptions being globally allocated

2021-08-15 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Sunday, 15 August 2021 at 16:23:25 UTC, Ali Çehreli wrote: That output contains two automatically chained exceptions: Failed: Main failed This failed too: The destructor failed Ali Hmm, wasn't aware of such use case (results of too much java :)). Considering this case I'd say it is

Re: Drawbacks of exceptions being globally allocated

2021-08-16 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Monday, 16 August 2021 at 06:12:14 UTC, Tejas wrote: ... Fyi, check out std.exeprimental.allocator package. You can use allocators from there to do allocation of exceptions, on the heap or any other region.

Re: simple (I think) eponymous template question ... what is proper idimatic way ?

2021-08-17 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Tuesday, 17 August 2021 at 18:11:56 UTC, james.p.leblanc wrote: Is there a more elegant way, to do this? Regards, James PS Any violations should be caught at compile time. That is template specialization: ``` auto moo(T : YourSpecialClassOrDType)(T myMoo) {•••} ``` You can also declare

Re: simple (I think) eponymous template question ... what is proper idimatic way ?

2021-08-17 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Tuesday, 17 August 2021 at 19:53:52 UTC, james.p.leblanc wrote: Wow! That is absolutely beautiful ... I had never seen (or even imagined) a recursive template! This expands my mind in a good way ... and is going into my toolbox immediately. Best Regards, James Just don't over rely on

Re: foreach() behavior on ranges

2021-08-24 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Tuesday, 24 August 2021 at 09:15:23 UTC, bauss wrote: A range should be a struct always and thus its state is copied when the foreach loop is created. Actually the range contracts don't mention that it needs to be a by value type. It can also be a reference type, i.e. a class. Which

Re: foreach() behavior on ranges

2021-08-24 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Tuesday, 24 August 2021 at 08:36:18 UTC, frame wrote: How do you handle that issue? Are your ranges designed to have this bug or do you implement opApply() always? This is expected behavior imho. I think what you need is a forward range, not input range. By the contract of input range, it

Re: foreach() behavior on ranges

2021-08-25 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Wednesday, 25 August 2021 at 11:04:35 UTC, Steven Schveighoffer wrote: It never has called `save`. It makes a copy, which is almost always the equivalent `save` implementation. -Steve Really? Then what is the use for .save method then? The only reason I can find is that you can't declare

Re: foreach() behavior on ranges

2021-08-25 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Wednesday, 25 August 2021 at 06:51:36 UTC, bauss wrote: Of course it doesn't disallow classes but it's generally advised that you use structs and that's what you want in 99% of the cases. It's usually a red flag when a range starts being a reference type. Well, sometimes you can't avoid

Re: foreach() behavior on ranges

2021-08-25 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Wednesday, 25 August 2021 at 08:15:18 UTC, frame wrote: I know, but foreach() doesn't call save(). Hmm, this is a regression probably, or I missed the time frame when foreach moved to use of copy constructor for forward ranges. Do we have a well defined description of what input, forward

Re: Getting a working example of opIndexAssign using opSlice ... have troubles ...

2021-08-16 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Monday, 16 August 2021 at 06:36:02 UTC, james.p.leblanc wrote: To be honest, I am not exactly sure what is happening here. I am unfamiliar with the "(T : T[])" syntax ... need to read That is template argument secialization. You're saying that T can be accept only types that are arrays of

Re: Drawbacks of exceptions being globally allocated

2021-08-14 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Saturday, 14 August 2021 at 13:24:22 UTC, Tejas wrote: ... I don't think there are any gotchas here. The problem with this technique, is when your exceptions aren't just simple labels but also carry some additional data, say for example specific error type, and subject that, caused this.

Re: Lexicographical object comparison by selected members of a struct

2021-08-20 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Saturday, 21 August 2021 at 04:34:46 UTC, Ali Çehreli wrote: ... Consider __traits(identifier, member) instead. This one should return member name as string, removing the need of memberName function. Also you could have an annotation @Equality.Include for example, and make mixin scan

Re: Lexicographical object comparison by selected members of a struct

2021-08-20 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Saturday, 21 August 2021 at 05:34:59 UTC, Alexandru Ermicioi wrote: ... Also there is no need for mixing string code here. You can get the field using __traits(getMember, this, member).

Re: Drawbacks of exceptions being globally allocated

2021-08-15 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Sunday, 15 August 2021 at 00:15:32 UTC, Ali Çehreli wrote: Even though this feature is probably never used, in D, multiple exception objects are chained. For example, you can throw e.g. in a destructor when there is an active exception in flight and that second object gets attached to the

Re: __traits() to get parameter details only ? ... hasMember looks up everything within

2021-08-04 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Wednesday, 4 August 2021 at 15:08:24 UTC, someone wrote: However, __traits(hasMember, ...) checks for the existence of anything labeled lstrCurrencyID within the class (eg: unrelated variables with same name; not gonna happen, but, I like to code it the right way); so, question is: is

Re: __traits() to get parameter details only ? ... hasMember looks up everything within

2021-08-04 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Wednesday, 4 August 2021 at 22:28:53 UTC, someone wrote: Is that what you mean ? Not really. I was assuming you were talking about @property methods, and if so you could declare such cases: ``` interface HasMutableLstrSymbolId { @property lstrSymbolId(); @property lstrSymbolId(string

Re: I like dlang but i don't like dub

2022-03-21 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Friday, 18 March 2022 at 21:04:03 UTC, H. S. Teoh wrote: On Fri, Mar 18, 2022 at 11:16:51AM -0700, Ali Çehreli via Digitalmars-d-learn wrote: tldr; I am talking on a soap box with a big question mind hovering over on my head: Why can't I accept pulling in dependencies automatically?

Pure D frontend as library.

2022-12-26 Thread Alexandru Ermicioi via Digitalmars-d-learn
Hi team, I'd like to ask a lazy question: How easy is to use D compiler frontend without backend? How complicated would be to write a transpiler, and from which files should you start modifications? I'm wondering if something like https://typescripttolua.github.io/ could be done, but with d

Re: Pure D frontend as library.

2022-12-27 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Monday, 26 December 2022 at 23:08:59 UTC, Richard (Rikki) Andrew Cattermole wrote: ... That on the other hand... Yeah, things aren't great on that front. The thing you want to implement is what we call glue code and isn't really setup right now for this (nobody has tried like this,

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

2022-11-21 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Monday, 21 November 2022 at 11:34:50 UTC, thebluepandabear wrote: Best regards, Alexandru. Thanks but I haven't reached that yet. Well, I wish you'll reach as soon as possible :)

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

2022-11-21 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Monday, 21 November 2022 at 11:20:31 UTC, Alexandru Ermicioi wrote: On Thursday, 17 November 2022 at 04:39:35 UTC, thebluepandabear wrote: [...] Dunno if someone mentioned, but you can minimize use of boilerplate by hiding it into mixin templates. Say you have: ```D mixin template

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

2022-11-21 Thread Alexandru Ermicioi 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

Re: Operator "+=" overloading for class?

2023-12-18 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Sunday, 17 December 2023 at 04:13:20 UTC, Ki Rill wrote: I am trying to overload `opOpAssign` for my class. The code compiles, but it does not seem to be working. ```d // binary operations have already been implemented for Value // i need +=, -=, *=, /= auto opOpAssign(string op)(Value rhs)

Re: Web APis

2023-12-31 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Sunday, 31 December 2023 at 04:40:02 UTC, Axel Casillas wrote: Hi there, I'm trying to implement web api's into a terminal program. With some help at the IRC have gotten pretty far but just hit a roadblock trying to manipulate the web api to accept input from the user. Example: auto

Re: How to implement filterMap

2023-12-31 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Sunday, 31 December 2023 at 09:47:27 UTC, Siarhei Siamashka wrote: Also take a look at the `c` array. The handling of arithmetic overflows is a safety problem of the D language design. Certain types of input may cause overflows, which result in producing bogus data as a result of running

Re: interface opEquals

2023-11-24 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Friday, 24 November 2023 at 17:39:10 UTC, Antonio wrote: ... Dunno if this might help, but I noticed that `==` sometimes calls `opEquals(const Object) const` instead of overload defined on class/interface, you might try and override it as well, and delegate to your overload that deals

Re: interface opEquals

2023-11-27 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Monday, 27 November 2023 at 09:53:48 UTC, Antonio wrote: ...but why? All classes (and interfaces I think), at root of inheritance have `Object` class, this class defines couple of generic methods, you can find this class in object.d btw. One of those methods is `bool opEquals(const

Re: Branching of a discussion in forums?

2024-01-29 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Monday, 29 January 2024 at 14:59:23 UTC, Richard (Rikki) Andrew Cattermole wrote: If you are using a NewsGroup reader like ThunderBird it should be possible to branch off and post in a different one. What about web interface? Although nobody does that, normally people rename the subject

Branching of a discussion in forums?

2024-01-29 Thread Alexandru Ermicioi via Digitalmars-d-learn
Hi everyone, So just wondering is it possible to branch off a thread into new one (viewable as separate item in forum group)? Also, is it possible to branch into a different gruop all toghether? I.e. from "blabla" thread in announce to "some other thing" thread in learn for example?

Re: opApply + const

2024-01-23 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Tuesday, 23 January 2024 at 16:11:25 UTC, ryuukk_ wrote: Hello, I have the following: ```D struct Stuff { int opApply(scope int delegate(Stuff*) dg) { return 0; } }; void main() { Stuff* stuff; foreach(it; *stuff) {} } ``` It works fine.. but when the

Re: Struct copy constructor with inout

2023-11-14 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Tuesday, 14 November 2023 at 08:50:34 UTC, dhs wrote: In other words: why doesn't ss2=s2 fail here? Thanks, dhs Seems like it isn't called at all, your copy constructor with inout. Could be a bug. My assumption is that default copy constructors are generated alongside inout one, and

Re: How can I get the total memory size of a Jagged Array

2023-11-14 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Monday, 13 November 2023 at 14:15:31 UTC, seany wrote: Is there a better way? I want a method that works for every variable type including classes and objects. Thank you Perhaps, use length property of string. It should tell you length of a string and then you multiply it by size of

Re: impure

2024-04-08 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Sunday, 24 March 2024 at 07:41:41 UTC, Dom DiSc wrote: I'm creating a library that is completely pure, but it doesn't compile with pure: at the top because of one impure unittest (which uses random to test some things only probabilistic)! So do I really need to declare every function pure

Re: impure

2024-04-08 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Monday, 8 April 2024 at 07:53:01 UTC, Dom DiSc wrote: On Sunday, 24 March 2024 at 07:41:41 UTC, Dom DiSc wrote: Try `debug unittest {...}`? Cool. This seems to work. That's a nice workaroud for tests. Yay! Nice, fyi, you can use it with statements inside function bodies as well.

Re: Adapting foreign iterators to D ranges

2024-04-22 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Monday, 22 April 2024 at 11:36:43 UTC, Chloé wrote: The first implementation has the advantage is being simpler and empty being const, but has the downside that next is called even if the range ends up not being used. Is either approach used consistently across the D ecosystem? You can

Template detection

2015-09-13 Thread Alexandru Ermicioi via Digitalmars-d-learn
Hello, Given: class SomeClass { public { void someSimpleMethod() {} template setOfTemplatedMethods(Type) { void templatedMethodOne() {} void templatedMethodTwo() {} } } } Is there a way to detect at compile time if a member of

Why getting private member fails using getMember trait in a template?

2015-09-26 Thread Alexandru Ermicioi via Digitalmars-d-learn
Suppose we have, two modules: module testOne; import std.traits; template getMember(alias T, string member) { alias getMember = Identity!(__traits(getMember, T, member)); } module app; import testOne; import std.traits; class TestOne { private { int property; }

Re: Why getting private member fails using getMember trait in a template?

2015-09-29 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Saturday, 26 September 2015 at 10:10:39 UTC, Alexandru Ermicioi wrote: Suppose we have, two modules: module testOne; [...] So, is this behavior correct? If yes, then why?

Re: Template detection

2015-09-22 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Tuesday, 22 September 2015 at 15:37:32 UTC, Meta wrote: On Sunday, 13 September 2015 at 08:26:55 UTC, Alexandru Ermicioi wrote: Hello, Given: class SomeClass { public { void someSimpleMethod() {} template setOfTemplatedMethods(Type) { void

Re: Template detection

2015-09-22 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Sunday, 13 September 2015 at 09:29:13 UTC, Enamex wrote: On Sunday, 13 September 2015 at 08:26:55 UTC, Alexandru Ermicioi wrote: Hello, Given: class SomeClass { public { void someSimpleMethod() {} template setOfTemplatedMethods(Type) { void

Wrap array into a range.

2016-03-05 Thread Alexandru Ermicioi via Digitalmars-d-learn
I have to pass an array to a function that accepts an input range. Therefore I need to transform somehow array into an input range. Is there a range that wraps an array in standard library?

Ascii string literal.

2016-05-06 Thread Alexandru Ermicioi via Digitalmars-d-learn
Good day, Is it possible somehow to convert implicitly a string literal into an ubyte array? For example: void do(immutable(ubyte)[] asciiString) { // Do something with ascii string. } And from another section of code, calling it like: do("Some ascii string"); --- If no, is there