Re: std.string.assumeUTF() silently casting mutable to immutable?

2024-02-14 Thread RazvanN via Digitalmars-d-learn
On Wednesday, 14 February 2024 at 11:56:29 UTC, Forest wrote: On Wednesday, 14 February 2024 at 10:57:42 UTC, RazvanN wrote: This has already been fixed, you just need to use -preview=fixImmutableConv. This was put behind a preview flag as it introduces a breaking change. I just tried that

Re: Is it possible to do this with a template?

2021-12-17 Thread RazvanN via Digitalmars-d-learn
On Friday, 17 December 2021 at 07:52:18 UTC, rempas wrote: I want to use an expression and put it in place inside the `if` parentheses. The expression is: `is(typeof(val) == type)`. I want to use a template called "is_same" that will take the value and a type to place them to the respective

Re: template ctor overload Segmentation fault

2021-12-14 Thread RazvanN via Digitalmars-d-learn
On Sunday, 12 December 2021 at 11:57:43 UTC, vit wrote: Hello, why does this code fail to compile? ```d struct Foo(T){ this(Rhs, this This)(scope Rhs rhs){ } this(ref scope typeof(this) rhs){ } } struct Bar{ Foo!int foo; } void main(){ } ``` error: Segmentation

Re: template ctor overload Segmentation fault

2021-12-14 Thread RazvanN via Digitalmars-d-learn
On Tuesday, 14 December 2021 at 13:02:16 UTC, Tejas wrote: On Tuesday, 14 December 2021 at 12:04:36 UTC, RazvanN wrote: [...] Then why did my modification work? ```d struct Foo(T){ this(Rhs, this This)(scope Rhs rhs){ } this(scope Foo!(T)* rhs){ //replaced typeof(this) with

Re: template ctor overload Segmentation fault

2021-12-14 Thread RazvanN via Digitalmars-d-learn
On Sunday, 12 December 2021 at 11:57:43 UTC, vit wrote: Hello, why does this code fail to compile? ```d struct Foo(T){ this(Rhs, this This)(scope Rhs rhs){ } this(ref scope typeof(this) rhs){ } } struct Bar{ Foo!int foo; } void main(){ } ``` error: Segmentation

Re: No rdmd.exe in /bin64 on Windows - is this an issue?

2021-07-16 Thread RazvanN via Digitalmars-d-learn
On Monday, 12 July 2021 at 23:57:37 UTC, Scotpip wrote: Hi guys Just installed the DMD 2.097.0 .exe download for Windows on my 64 bit Win 10 workstation. [...] PR: https://github.com/dlang/installer/pull/484

Re: Cannot call find with haystack elements having a explicit copy constructors

2021-07-15 Thread RazvanN via Digitalmars-d-learn
On Thursday, 15 July 2021 at 11:08:25 UTC, Per Nordlöw wrote: The adding of copy construtors to `Service` defined as ```d @safe struct Service { this(ref return scope typeof(this) rhs) {} this(const ref return scope typeof(this) rhs) const {} } @safe struct Session { void

Re: Bug?

2020-05-05 Thread RazvanN via Digitalmars-d-learn
On Tuesday, 5 May 2020 at 05:37:08 UTC, Simen Kjærås wrote: On Tuesday, 5 May 2020 at 04:02:06 UTC, RazvanN wrote: [...] Surely the above code, which silently discards the exception, does not print "hello"? Regardless, I ran your code with writeln inside the catch(), and without the

Bug?

2020-05-04 Thread RazvanN via Digitalmars-d-learn
truct K { ~this() nothrow {} } void main() { static class C { this(K, int) {} } static int foo(bool flag) { if (flag) throw new Exception("hello"); return 1; } try { new C(K(), foo(true)); }

Re: std.container.rbtree as Interval Tree?

2019-02-05 Thread RazvanN via Digitalmars-d-learn
On Monday, 4 February 2019 at 22:54:01 UTC, James Blachly wrote: I tried to implement an interval tree backed by std.container.rbtree today and fell flat. [...] You can use alias this [1] in your interval element type: struct IntervalElem { size_t start, end; /* ... other

Re: Segfault when adding a static destructor in druntime/src/rt/sections_elf_shared.d

2019-01-11 Thread RazvanN via Digitalmars-d-learn
On Thursday, 10 January 2019 at 23:04:37 UTC, Steven Schveighoffer wrote: On 1/10/19 5:12 PM, RazvanN wrote: On Thursday, 10 January 2019 at 15:04:25 UTC, Steven Schveighoffer wrote: On 1/8/19 7:54 AM, RazvanN wrote: [...] That is a thread-local static destructor. Are any shared static

Re: Segfault when adding a static destructor in druntime/src/rt/sections_elf_shared.d

2019-01-10 Thread RazvanN via Digitalmars-d-learn
On Thursday, 10 January 2019 at 15:04:25 UTC, Steven Schveighoffer wrote: On 1/8/19 7:54 AM, RazvanN wrote: [...] That is a thread-local static destructor. Are any shared static destructors accessing the array? No, there aren't. Indeed, the problem is as Johan as said: the loadedDSOs

Re: Segfault when adding a static destructor in druntime/src/rt/sections_elf_shared.d

2019-01-10 Thread RazvanN via Digitalmars-d-learn
On Tuesday, 8 January 2019 at 14:30:24 UTC, Johan Engelen wrote: On Tuesday, 8 January 2019 at 12:54:11 UTC, RazvanN wrote: [...] Great! (I am _extremely_ surprised that dtors are not called for globals.) [...] Thanks! This is really helpful! RazvanN

Segfault when adding a static destructor in druntime/src/rt/sections_elf_shared.d

2019-01-08 Thread RazvanN via Digitalmars-d-learn
Hi all, I am working on issue 14650 [1] and I would like to implement a solution where static destructors are destroying global variables. However, I have the following problem in druntime/src/rt/sections_elf_shared: struct ThreadDSO { DSO* _pdso; static if (_pdso.sizeof == 8) uint

Re: Disabling struct destructor illegal?

2018-07-19 Thread RazvanN via Digitalmars-d-learn
On Thursday, 19 July 2018 at 09:50:32 UTC, Jim Balter wrote: On Thursday, 19 July 2018 at 08:50:15 UTC, RazvanN wrote: struct A { int a; @disable ~this() {} } void main() { A a = A(2); } Currently, this code yields: Error: destructor `A.~this` cannot be used because it is

Disabling struct destructor illegal?

2018-07-19 Thread RazvanN via Digitalmars-d-learn
struct A { int a; @disable ~this() {} } void main() { A a = A(2); } Currently, this code yields: Error: destructor `A.~this` cannot be used because it is annotated with @disable I was expecting that disabling the destructor would make it as if the struct does not have a

Re: Class qualifier vs struct qualifier

2018-06-14 Thread RazvanN via Digitalmars-d-learn
Honestly, from what I understand of how this works, what I find weird is the struct case. immutable on classes does _not_ make the class itself immutable. It just makes all of its members immutable - hence the error about trying to allocate new Foo instead of new immutable Foo. So, that is

Class qualifier vs struct qualifier

2018-06-13 Thread RazvanN via Digitalmars-d-learn
Hello, I'm having a hard time understanding whether this inconsistency is a bug or intended behavior: immutable class Foo {} immutable struct Bar {} void main() { import std.stdio : writeln; Foo a; Bar b; writeln("typeof(a): ", typeof(a).stringof); writeln("typeof(b): ",

Constructor qualifiers; bug or expected behavior?

2018-04-02 Thread RazvanN via Digitalmars-d-learn
Hi all, Let's say we have this code: struct B { int a; this(int a) immutable { this.a = 7; } this(int a) { this.a = 10; } } void main() { B a = immutable B(2); writeln(a.a); a.a = 4; immutable B a2 = immutable B(3);

Re: Understanding the AST...

2018-02-22 Thread RazvanN via Digitalmars-d-learn
On Thursday, 22 February 2018 at 13:21:04 UTC, joe wrote: On Monday, 12 February 2018 at 08:47:58 UTC, RazvanN wrote: Hi Joe, /SNIP On Tuesday, 6 February 2018 at 12:03:06 UTC, joe wrote: [...] The FuncDeclaration node contains all the information for that. For example, you can access

Re: How to check if aggregate member is static templated method?

2018-02-15 Thread RazvanN via Digitalmars-d-learn
On Thursday, 15 February 2018 at 13:51:41 UTC, drug wrote: 15.02.2018 16:50, drug пишет: https://run.dlang.io/is/zHT2XZ I can check againts if member is either static function or template. But I failed to check if it both static and templated. The best I could come up with is: struct Foo {

Re: Understanding the AST...

2018-02-12 Thread RazvanN via Digitalmars-d-learn
Hi Joe, I suggest you watch this video which explains how the parse time visitors work: https://www.youtube.com/watch?v=tK072jcoWv4 . On Tuesday, 6 February 2018 at 12:03:06 UTC, joe wrote: Hello everybody! Last week end I found this post (

Re: ddox empty public methods/interfaces etc

2017-11-10 Thread RazvanN via Digitalmars-d-learn
On Thursday, 9 November 2017 at 14:21:52 UTC, Steven Schveighoffer wrote: On 11/8/17 10:45 PM, Andrey wrote: I just added to dub.json this: "-ddoxFilterArgs": [     "--min-protection=Public" ] i.e. without --only-documented option, in this way ddox will generate documentation for all

Re: std.concurrency.setMaxMailboxSize

2017-10-11 Thread RazvanN via Digitalmars-d-learn
On Wednesday, 11 October 2017 at 11:26:11 UTC, rikki cattermole wrote: On 11/10/2017 12:09 PM, RazvanN wrote: Hi all, I have seen that the concurrency api has this method specified in $title [1] and I was wondering what is the use of it? Enabling threads to modify the message box of other

std.concurrency.setMaxMailboxSize

2017-10-11 Thread RazvanN via Digitalmars-d-learn
Hi all, I have seen that the concurrency api has this method specified in $title [1] and I was wondering what is the use of it? Enabling threads to modify the message box of other threads doesn't seem to be a good idea and I can't think of any real use case. Best regards, RazvanN [1]

Re: D bindings for TensorFlow

2017-01-06 Thread RazvanN via Digitalmars-d-learn
On Friday, 6 January 2017 at 13:22:28 UTC, llaine wrote: Did anyone used Tensorflow with D ? I would be really interesting to know if some libs allows it right now. I read an old thread about TS on the forum, but since then nothing ... At the moment there is no support in D to use

Re: Swap front for char[] input ranges

2016-12-21 Thread RazvanN via Digitalmars-d-learn
On Monday, 19 December 2016 at 20:26:26 UTC, Ali Çehreli wrote: On 12/19/2016 06:09 AM, RazvanN wrote: > [...] wrote: >> [...] InputRanges. >> [...] following > [...] char[] > [...] function, so > [...] http://dlang.org/phobos/std_algorithm_mutation.html#bringToFront [...] No need to mention

Re: Swap front for char[] input ranges

2016-12-19 Thread RazvanN via Digitalmars-d-learn
On Monday, 19 December 2016 at 12:25:02 UTC, Ali Çehreli wrote: On 12/19/2016 02:41 AM, RazvanN wrote: > [...] As your comments make it clear below, they cannot be InputRanges. > [...] swapping code > [...] Obivously, tmp1 and tmp2 are unusued there. :) > [...] passed. > [...]

Swap front for char[] input ranges

2016-12-19 Thread RazvanN via Digitalmars-d-learn
Hi, I have a function which accepts 2 input Ranges and swaps the first element in Range1 with the first element in Range2. The swapping code looks something like this : static if (is(typeof(swap(r1.front, r2.front { swap(r1.front, r2.front); } else {

Range of uncopyable elements

2016-12-08 Thread RazvanN via Digitalmars-d-learn
Hi, I am trying to create a range with uncopyable elements. My thought process was the following: 1.I have created a struct : struct S { int a; @disable this(this); } 2. I declared an array : S[] arr = [S(1), S(2), S(3)]; expecting that arr will be a range like, for example, an

Re: Char representation

2016-11-22 Thread RazvanN via Digitalmars-d-learn
On Tuesday, 22 November 2016 at 14:23:28 UTC, Jonathan M Davis wrote: On Tuesday, November 22, 2016 13:29:47 RazvanN via Digitalmars-d-learn wrote: [...] You misunderstand. char[] is a dynamic array of char, wchar[] is a dynamic array of wchar[], and dchar[] is a dynamic array of dchar

Char representation

2016-11-22 Thread RazvanN via Digitalmars-d-learn
Given the following code: char[5] a = ['a', 'b', 'c', 'd', 'e']; alias Range = char[]; writeln(is(ElementType!Range == char)); One would expect that the program will print true. In fact, it prints false and I noticed that if Range is char[], wchar[], dchar[], string, wstring, dstring

Re: The return of std.algorithm.find

2016-11-15 Thread RazvanN via Digitalmars-d-learn
On Tuesday, 15 November 2016 at 09:43:27 UTC, RazvanN wrote: The find function which receives an input haystack and a needle returns the haystack advanced to the first occurrence of the needle. For normal ranges this is fine, but for sorted ranges (aka SortedRange) it is a bit odd. For

The return of std.algorithm.find

2016-11-15 Thread RazvanN via Digitalmars-d-learn
The find function which receives an input haystack and a needle returns the haystack advanced to the first occurrence of the needle. For normal ranges this is fine, but for sorted ranges (aka SortedRange) it is a bit odd. For example: find(assumeSorted[1, 2, 4, 5, 6, 7], 4) would return [4, 5,

Re: Concatenate 2 ranges

2016-11-11 Thread RazvanN via Digitalmars-d-learn
On Friday, 11 November 2016 at 13:33:20 UTC, Vladimir Panteleev wrote: On Friday, 11 November 2016 at 13:30:17 UTC, RazvanN wrote: I know that I can use the .array property, but I think that this iterates through all of my elements. Using assumeSorted(chain(r1, r2).array) will return a

Concatenate 2 ranges

2016-11-11 Thread RazvanN via Digitalmars-d-learn
I am trying to concatenate 2 ranges of the same type (SortedRange in my case). I have tried merge, join and chain, but the problem is that the result is not an object of the type of the initial ranges. For example: 1. If I use chain(r1, r2), the result will be an object of type Result which

Re: is operator and SortedRange

2016-11-11 Thread RazvanN via Digitalmars-d-learn
On Friday, 11 November 2016 at 12:02:10 UTC, ketmar wrote: On Friday, 11 November 2016 at 11:49:25 UTC, RazvanN wrote: [...] template isSortedRange(T) { private import std.range : SortedRange; static if (is(T : SortedRange!TT, TT)) { enum isSortedRange = true; } else { enum

is operator and SortedRange

2016-11-11 Thread RazvanN via Digitalmars-d-learn
I am a bit confused about how the is operator works. I have a function which receives an InputRange and a predicate. Now I need to be able to test if the InputRange is actually a SortedRange. I don't care about how the datatypes behind the SortedRange or the predicate, I just need to see if

Obtain predicate from SortedRange

2016-11-09 Thread RazvanN via Digitalmars-d-learn
Given a SortedRange object, is there a way to obtain the predicate which was used for it to be sorted?

Re: typeof(SortedRange) and is operator

2016-11-08 Thread RazvanN via Digitalmars-d-learn
On Tuesday, 8 November 2016 at 13:59:19 UTC, Nicholas Wilson wrote: On Tuesday, 8 November 2016 at 13:22:35 UTC, RazvanN wrote: Sorry, I accidentally posted the above message and I don't know how to erase it. You can't, this is a mailing list not a forum. The following post is the complete

Re: typeof(SortedRange) and is operator

2016-11-08 Thread RazvanN via Digitalmars-d-learn
Sorry, I accidentally posted the above message and I don't know how to erase it. The following post is the complete one: Given the following code: int[] arr = [1, 2, 9, 4, 10, 6]; auto r= sort(arr); if(is(typeof(r) == SortedRange!(int[], "a

typeof(SortedRange) and is operator

2016-11-08 Thread RazvanN via Digitalmars-d-learn
Given the following code: int[] arr = [1, 2, 9, 4, 10, 6]; auto r= sort(arr); if(is(typeof(r) == SortedRange!(int[], "a