Re: How to find all modules in a package?

2022-08-03 Thread Piotr Mitana via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 03:36:55 UTC, Domain wrote: I want to find out all public functions in all modules in a package. Can I do that at compile time? I think it's not possible.

Re: Return values from auto function

2020-11-07 Thread Piotr Mitana via Digitalmars-d-learn
On Friday, 6 November 2020 at 10:51:20 UTC, Andrey Zherikov wrote: struct Result(T) { struct Success { static if(!is(T == void)) { T value; } } struct Failure { string error; } Algebraic!(Success, Failure) result;

Re: What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-30 Thread Piotr Mitana via Digitalmars-d-learn
On Sunday, 22 December 2019 at 17:20:51 UTC, BoQsc wrote: There are lots of editors/IDE's that support D language: https://wiki.dlang.org/Editors What kind of editor/IDE are you using and which one do you like the most? IntelliJ IDEA CE with this extension:

Re: Cannot take the .keys of shared AA. Is this a regression in 2.087 or a feature?

2019-08-16 Thread Piotr Mitana via Digitalmars-d-learn
On Thursday, 15 August 2019 at 19:51:30 UTC, Jonathan M Davis wrote: Not being able to implicitly convert to const is a bit odd, but arguably, nothing should ever be called on a shared AA anyway. If an operation isn't thread-safe, then it shouldn't work with shared. To use a shared object

Cannot take the .keys of shared AA. Is this a regression in 2.087 or a feature?

2019-08-15 Thread Piotr Mitana via Digitalmars-d-learn
Code: import std; shared(string[string]) dict; void main() { dict.keys; } Error: /dlang/dmd/linux/bin64/../../src/druntime/import/object.d(3417): Error: cannot implicitly convert expression aa of type shared(string[string]) to const(shared(string)[string]) onlineapp.d(7): Error:

Re: Is there a function for this?

2018-10-08 Thread Piotr Mitana via Digitalmars-d-learn
On Saturday, 6 October 2018 at 13:17:22 UTC, bauss wrote: Let's say you have a range with struct, but some of the struct are duplicates of each other. Is there a standard function in Phobos to remove duplicates? My first thought was "uniq", but it can't really do it like that, but it doesn't

@safe - why does this compile?

2018-07-13 Thread Piotr Mitana via Digitalmars-d-learn
This code: import std.stdio; class X1 {} class X2 : X1 { void run() @safe { writeln("DONE"); } } void main() @safe { X1 x1 = new X1; X2 x2 = cast(X2) x1; x2.run(); } is obviously wrong gets killed by

Re: vibe.d: problematic "Non-@safe methods are deprecated in REST interfaces"

2018-07-11 Thread Piotr Mitana via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 13:24:43 UTC, WebFreak001 wrote: It's supposed to make webservers safe and not crash because of segmentation faults, etc. If you still want to write code like you are used to and don't care about that in your webserver, just mark everything in the implementation

vibe.d: problematic "Non-@safe methods are deprecated in REST interfaces"

2018-07-10 Thread Piotr Mitana via Digitalmars-d-learn
Hello, I've recently started building a little REST application on vibe.d. I decided to use the "database" library, as I need to communicate with the PostgreSQL instance. During the compilation I see the deprecation warning: "Non-@safe methods are deprecated in REST interfaces" So two

Re: Sealed classes - would you want them in D? (v2)

2018-05-17 Thread Piotr Mitana via Digitalmars-d
On Thursday, 17 May 2018 at 02:32:07 UTC, KingJoffrey wrote: I propose an idea, for discussion (robust discussion even better ;-) Add an new attribute to class, named 'sealed'. No, not sealed as in Scala. No, not sealed as in C# sealed as in oxford dictionary (close securely, non-porous).

Re: Sealed classes - would you want them in D?

2018-05-14 Thread Piotr Mitana via Digitalmars-d
On Saturday, 12 May 2018 at 15:36:56 UTC, Walter Bright wrote: On 5/12/2018 8:18 AM, Piotr Mitana wrote: What I am trying to do is: == a.d class P { private this(); } final class C1 : P { } final class C2 : P { } test.d import a; void foo()

Re: Sealed classes - would you want them in D?

2018-05-12 Thread Piotr Mitana via Digitalmars-d
On Saturday, 12 May 2018 at 10:27:11 UTC, Walter Bright wrote: The solution is: private class MyClass { ... } public final MyClassSealed : MyClass { } Meaning other modules can use MyClassSealed but cannot derive from it. Other classes inside the module can derive from MyClass as

Re: Sealed classes - would you want them in D?

2018-05-12 Thread Piotr Mitana via Digitalmars-d
On Friday, 11 May 2018 at 23:28:48 UTC, Jonathan M Davis wrote: Except that if I understand correctly, what the OP wants is to have the class be publicly available while restricting who's allowed to derive from it, with the idea that a particular class hierarchy would have a well-defined set

Re: Sealed classes - would you want them in D?

2018-05-11 Thread Piotr Mitana via Digitalmars-d
On Friday, 11 May 2018 at 15:02:08 UTC, jmh530 wrote: But a new keyword will not get added without a DIP. Yes, I know it definitely needs a DIP - I've opened a discussion in order to gather community members' opinions on sealed and decide whether to write this DIP at all and possibly track

Re: Sealed classes - would you want them in D?

2018-05-11 Thread Piotr Mitana via Digitalmars-d
Might I suggest going back to the sealed classes topic? I don't think the discussion in this thread should go in the direction about the sense of using classes, proper encapsulation and the memory related stuff.

Re: Sealed classes - would you want them in D?

2018-05-11 Thread Piotr Mitana via Digitalmars-d
On Thursday, 10 May 2018 at 14:48:23 UTC, rikki cattermole wrote: module foo; class A { } final class B : A {    } in one module, he wants to be able to create a new final class C : B {    } and keep class B as final so that no one else can extend it in another module. Not entirely.

Sealed classes - would you want them in D?

2018-05-10 Thread Piotr Mitana via Digitalmars-d
Hello, I've recently thought of sealed classes (sealed as in Scala, not as in C#) and am thinking of writing a DIP for it. I decided to start this thread first though to gather some opinions on the topic. For those who never coded Scala and don't know sealed classes: a sealed class is a

Package method is not virtual and cannot override - a bug or a feature?

2018-05-10 Thread Piotr Mitana via Digitalmars-d-learn
Given this code: abstract class A { package @property void x(int x); package @property int x(); } class B : A { package @property override void x(int x) {} package @property override int x() { return 0; } } void main() {} I get the following message: onlineapp.d(9): Error:

Slide - what does withPartial do?

2018-03-01 Thread Piotr Mitana via Digitalmars-d-learn
For some reason this is true: slide!(Yes.withPartial)([1, 2, 3, 4, 5], 3).array == [[1, 2, 3], [2, 3, 4], [3, 4, 5]] Shouldn't it rather return [[1], [1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5], [5]], or at least [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5], [5]]? I can see no difference

getSymbolsByUDA does not take private symbols under consideration. Should I file a bug?

2018-02-16 Thread Piotr Mitana via Digitalmars-d-learn
Hello, The code below: import std.traits; enum Attr; class MyClass { private @Attr int a; static assert(getSymbolsByUDA!(typeof(this), MyClass).length == 1); } does not compile as static assertion fails. Making the filed a public makes it compile

Suggestion: needleless findSplit* methods

2017-12-12 Thread Piotr Mitana via Digitalmars-d
Hello, I'd like to make a little suggestion for phobos: enrich findSplit* method family with the "needleless" predicate option. Motivation: Let's have a range of string tokens that - after cutting of the initial brace - looks like this: auto range = ["23", "42", "14.3", "-323", "}"]

One path skips constructor - is this a bug?

2017-09-07 Thread Piotr Mitana via Digitalmars-d-learn
Code: === import std.conv; import std.regex; struct A { int field1; int field2; this(int field1, int field2) { if(field1 > field2) throw new Exception("This is illegal!"); }

Base class' constructor is not implicitly inherited for immutable classes. A bug or a feature?

2017-07-19 Thread Piotr Mitana via Digitalmars-d-learn
Hello, I have this code: immutable class Base { this() {} } immutable class Derived : Base {} void main() { new immutable Derived(); } I'd like class Derived to automatically inherit the default constructor from Base. However, this is not the case: main.d(6): Error: class

Re: Snap packages for DMD and DUB

2017-06-06 Thread Piotr Mitana via Digitalmars-d-announce
On Monday, 8 May 2017 at 20:05:01 UTC, Joseph Rushton Wakeling wrote: Hello all, As announced at DConf 2017, snap packages are now available for DMD 2.074.0 and DUB 1.3.0 in the official snap store. These should allow for installation on multiple different Linux distros (see below) on i386

Re: Snap packages for DMD and DUB

2017-05-11 Thread Piotr Mitana via Digitalmars-d-announce
On Monday, 8 May 2017 at 20:05:01 UTC, Joseph Rushton Wakeling wrote: Hello all, As announced at DConf 2017, snap packages are now available for DMD 2.074.0 and DUB 1.3.0 in the official snap store. These should allow for installation on multiple different Linux distros (see below) on i386