Re: How to simplify nested ifs

2018-03-16 Thread Satoshi via Digitalmars-d-learn
On Tuesday, 13 March 2018 at 12:23:06 UTC, Ozan Süel wrote: Hi I have a construction like the following if (source) { if (source.pool) { if (source.pool.repository) { if (source.pool.repository.directory) { if (source.pool.repository.directory.users) { // do

Re: Global variable type does not match previous declaration

2017-12-16 Thread Satoshi via Digitalmars-d-learn
On Saturday, 16 December 2017 at 09:04:05 UTC, Satoshi wrote: I commented out the TypeInfo declarations and got the same error but on different symbol. object.d(1569): Error: Function type does not match previously declared function with the same mangled name: _d_dynamic_cast

Re: Global variable type does not match previous declaration

2017-12-16 Thread Satoshi via Digitalmars-d-learn
I commented out the TypeInfo declarations and got the same error but on different symbol. object.d(1569): Error: Function type does not match previously declared function with the same mangled name: _d_dynamic_cast https://github.com/Rikarin/Trinix/blob/master/Kernel/object.d#L1569

Re: Global variable type does not match previous declaration

2017-12-14 Thread Satoshi via Digitalmars-d-learn
On Thursday, 14 December 2017 at 12:18:22 UTC, Nicholas Wilson wrote: On Wednesday, 13 December 2017 at 21:39:40 UTC, Satoshi wrote: On Wednesday, 13 December 2017 at 21:38:49 UTC, Satoshi wrote: [...] Compiling with ldc2 -debuglib= -defaultlib= -code-model=kernel -disable-red-zone -w -wi

Re: Global variable type does not match previous declaration

2017-12-13 Thread Satoshi via Digitalmars-d-learn
On Wednesday, 13 December 2017 at 21:38:49 UTC, Satoshi wrote: What means this error and how to solve it? object.d-mixin-1072(1112): Error: Global variable type does not match previous declaration with same mangled name: _D10TypeInfo_m6__initZ Actually, I'm working on OS with minimal D

Global variable type does not match previous declaration

2017-12-13 Thread Satoshi via Digitalmars-d-learn
What means this error and how to solve it? object.d-mixin-1072(1112): Error: Global variable type does not match previous declaration with same mangled name: _D10TypeInfo_m6__initZ Actually, I'm working on OS with minimal D runtime and I'm unable to compile object.d source code:

Re: Single exe vibe.d app

2017-04-06 Thread Satoshi via Digitalmars-d-learn
On Wednesday, 5 April 2017 at 12:42:23 UTC, evilrat wrote: On Wednesday, 5 April 2017 at 12:13:38 UTC, Satoshi wrote: Hi, How can I build single exe application with vibe.d (windows)? now it require zlib.dll, libeay32.dll and ssleay32.dll But I need it as single app. btw, if all you need is

Single exe vibe.d app

2017-04-05 Thread Satoshi via Digitalmars-d-learn
Hi, How can I build single exe application with vibe.d (windows)? now it require zlib.dll, libeay32.dll and ssleay32.dll But I need it as single app.

Re: How to continue after the book?

2017-03-28 Thread Satoshi via Digitalmars-d-learn
On Tuesday, 28 March 2017 at 07:27:31 UTC, I Lindström wrote: After getting the basics down, how did you continue when learning programming in general? 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

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

2017-03-11 Thread Satoshi 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

Create doc simultaneously with compilation

2017-02-19 Thread Satoshi via Digitalmars-d-learn
Why is not possible to create documentation, compile code and generate header files simultaneously? When I pass -D and -Dd flags to ldc2 command it won't create doc until I don't pass -o- flag too.

Re: Force inline

2017-02-19 Thread Satoshi via Digitalmars-d-learn
On Sunday, 19 February 2017 at 19:19:25 UTC, berni wrote: Is it possible to force a function to be inlined? Comparing a C++ and a D program, the main difference in speed (about 20-30%) is, because I manage to force g++ to inline a function while I do not find any means to do the same on D.

dep files

2017-02-01 Thread Satoshi via Digitalmars-d-learn
Hi, I'm using package.d file for the project, where is each file imported. In each file is imported only that one package file (like `import Foo;`). Problem is with .dep files. dep file for each source file contains all source files of the project just because it imports that package.

rtInfo()

2016-12-14 Thread Satoshi via Digitalmars-d-learn
Hello, is rtInfo() already used by GC? I need to store some data for each class so I'm using this template and m_rtInfo in TypeInfo_Class but now it seems that GC is not working properly in some cases. Thanks.

Re: @property

2016-12-09 Thread Satoshi via Digitalmars-d-learn
On Thursday, 8 December 2016 at 22:09:14 UTC, Jonathan M Davis wrote: On Thursday, December 08, 2016 16:54:57 Adam D. Ruppe via Digitalmars-d- learn wrote: [...] Yeah, it's pretty common for folks to slap @property on functions to make it clear that it's intended to be used as a property

@property

2016-12-08 Thread Satoshi via Digitalmars-d-learn
Hello, is there any advantage of marking function as @property?? class Foo { void objectValue(Object value) { } Object objectValue() { } } auto foo = new Foo; // This works fine without @property attribute foo.objectValue = null; auto bar = foo.objectValue;

Re: A simplification of the RvalueRef idiom

2016-11-22 Thread Satoshi via Digitalmars-d-learn
or I have simple class class View { this(Rectangle frame) {...} this(float, float, float, float) { ... } this(Point, Size) { ... } } then struct Point, Size and Rectangle (Point, Size) now I need to write 2 overloads for View class taking 4 floats or (Point, Size) and this must do in every

Re: A simplification of the RvalueRef idiom

2016-11-22 Thread Satoshi via Digitalmars-d-learn
On Tuesday, 22 November 2016 at 19:16:56 UTC, Ali Çehreli wrote: On 11/22/2016 08:05 AM, Satoshi wrote: I don't have extensive experience with other languages. In fact, the only other languages that I can claim proficiency are C and C++. (I also know Python just enough to find it incredible

Re: A simplification of the RvalueRef idiom

2016-11-22 Thread Satoshi via Digitalmars-d-learn
On Monday, 21 November 2016 at 20:04:51 UTC, Ali Çehreli wrote: First, a reminder that we have this great resource of D idioms: https://p0nce.github.io/d-idioms/#Rvalue-references:-Understanding-auto-ref-and-then-not-using-it The link above has an idiom of mixing in a byRef() member function

Re: null this

2016-11-21 Thread Satoshi via Digitalmars-d-learn
On Monday, 21 November 2016 at 10:25:17 UTC, Satoshi wrote: Hello, how can calling method on local struct throw "null this"? struct is initialized by .init and have default values. struct Foo { Bar bar; static struct Bar { float x, y, z; } Bar getBar() { return bar; } }

Re: null this

2016-11-21 Thread Satoshi via Digitalmars-d-learn
cast(ulong) but is not null. It won't work just in special cases what I cannot reproduce easily.

null this

2016-11-21 Thread Satoshi via Digitalmars-d-learn
Hello, how can calling method on local struct throw "null this"? struct is initialized by .init and have default values. struct Foo { Bar bar; static struct Bar { float x, y, z; } Bar getBar() { return bar; } } then Foo foo = Foo.init; auto b = foo.getBar(); // throw "null

Class copy

2016-11-10 Thread Satoshi via Digitalmars-d-learn
Hello, how can I copy class when I have pointer to the parent of it? eg. class Foo { int m_a; this(const(Foo) other) { m_a = other.m_a; } } class Bar : Foo { int m_b; this(const(Bar) other) { super(other); m_b = other.m_b; } R dup(this

Re: Typesafe variadic argument taking struct

2016-10-20 Thread Satoshi via Digitalmars-d-learn
On Thursday, 20 October 2016 at 16:04:00 UTC, Nordlöw wrote: On Thursday, 20 October 2016 at 12:48:34 UTC, Satoshi wrote: Hello, why ... cannot be used with structs? struct Foo { this(int a) { } } void bar(Foo foo...) { } bar(42); Being explicit about these things makes complex code

Re: Typesafe variadic argument taking struct

2016-10-20 Thread Satoshi via Digitalmars-d-learn
On Thursday, 20 October 2016 at 12:52:42 UTC, rikki cattermole wrote: On 21/10/2016 1:48 AM, Satoshi wrote: Hello, why ... cannot be used with structs? struct Foo { this(int a) { } } void bar(Foo foo...) { } bar(42); Because an int is not a Foo. Oh, really? I didn't notice that...

Typesafe variadic argument taking struct

2016-10-20 Thread Satoshi via Digitalmars-d-learn
Hello, why ... cannot be used with structs? struct Foo { this(int a) { } } void bar(Foo foo...) { } bar(42);

Re: ptrdiff_t of class.tupleof entry

2016-10-11 Thread Satoshi via Digitalmars-d-learn
On Monday, 10 October 2016 at 18:21:10 UTC, Jonathan M Davis wrote: On Monday, October 10, 2016 17:57:15 Satoshi via Digitalmars-d-learn wrote: [...] You can use the offsetof property of a member variable to find out the offset between its address and the address of the beginning

ptrdiff_t of class.tupleof entry

2016-10-10 Thread Satoshi via Digitalmars-d-learn
Hello, How can I take an ptrdiff_t of any tupleoff entry from class during compilation? I need something like this: template Test(T, int i) { enum Test = [i] - [0]; } and then use it like: class AnyClass { int a; int b; int c; string d; } enum Addr = Test!(AnyClass, 3); void

Re: Problems with "shared"

2016-10-10 Thread Satoshi via Digitalmars-d-learn
On Sunday, 9 October 2016 at 21:32:23 UTC, ag0aep6g wrote: On 10/09/2016 10:57 PM, jython234 wrote: 1. Where do I use the "shared" keyword? What doesn't work is creating an unshared object of a class that only has a shared constructor. To create both shared and unshared objects, you need

Re: Class attributes

2016-10-03 Thread Satoshi via Digitalmars-d-learn
On Sunday, 2 October 2016 at 17:22:57 UTC, Basile B. wrote: On Sunday, 2 October 2016 at 15:54:38 UTC, Satoshi wrote: Hello, why pure @safe nothrow @nogc struct Point { } isn't same as struct Point { pure: @safe: nothrow: @nogc: } ?? This is not specified but attributes aren't applied to

Class attributes

2016-10-02 Thread Satoshi via Digitalmars-d-learn
Hello, why pure @safe nothrow @nogc struct Point { } isn't same as struct Point { pure: @safe: nothrow: @nogc: } ??

Re: Easy sockets - don't exist yet?

2016-09-27 Thread Satoshi via Digitalmars-d-learn
On Monday, 26 September 2016 at 23:40:10 UTC, Vincent wrote: Hello, guys! I was very surprised that module 'socketstream' was deprecated. Usually if something become obsolete, there is some perfect replacement! But my digging in Inet and forums gave nothing, but "outdated" examples with

Re: Properties don't work as expected

2016-07-05 Thread Satoshi via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 10:52:10 UTC, zodd wrote: Property functions are used wrong by a compiler when it needs to get and set a value at the same time: [...] Try @property ref int value() { return value_; }

Re: executeShell doesn't work but system does

2016-06-27 Thread Satoshi via Digitalmars-d-learn
On Sunday, 26 June 2016 at 19:01:07 UTC, cym13 wrote: On Sunday, 26 June 2016 at 17:56:08 UTC, Satoshi wrote: On Sunday, 26 June 2016 at 15:37:03 UTC, "Smoke" Adams wrote: system("cls") works but executeShell doesn't. system is depreciated. What's going on? The docs say that it creates a new

Re: executeShell doesn't work but system does

2016-06-26 Thread Satoshi via Digitalmars-d-learn
On Sunday, 26 June 2016 at 15:37:03 UTC, "Smoke" Adams wrote: system("cls") works but executeShell doesn't. system is depreciated. What's going on? The docs say that it creates a new process. I simply want to clear the console! I have problem with executeShell on windows 10 (LDC 1.0.0)

Cannot find module during separate compilation

2016-06-10 Thread Satoshi via Digitalmars-d-learn
Hello, I have 2 files: source/test.d: module foo.test; and source/bar.d module foo.bar; import foo.test; When I am compiling this 2 files together there is no problem. But when I compile it with -c flag (LDC) compiler thrown an error (cannot find foo/test.d) Why isn't import path

operator overload for enum

2016-06-10 Thread Satoshi via Digitalmars-d-learn
Hello, why operator overloading is not working as a static methods through the UFCS? I need overload a << operator in this way: enum PlatformID { None, Trinix, Unix, MacOS, Windows } PlatformID toPlatformID(string platform) { switch

Re: How do you use D to launch/open a window?

2016-04-24 Thread Satoshi via Digitalmars-d-learn
On Friday, 22 April 2016 at 21:13:31 UTC, anonymousuer wrote: What code is needed to tell D to open a window? Thank you in advance. You can choose between existing libraries or wrappers for GUI implementation like: DlangUI, Qt, ..., (or my new GUI framework called Rikarin what will be

Re: Overriding a property ?

2016-04-14 Thread Satoshi via Digitalmars-d-learn
On Thursday, 14 April 2016 at 20:21:38 UTC, Lucien wrote: How can I override a property ? Test code: class A { @property bool foo { return false; } void myFunc() { ... } } class B : A { override bool foo { return true; } // error override void

Passing _arguments into another variadic function

2016-04-12 Thread Satoshi via Digitalmars-d-learn
Hello, I have a little problem with Variadic functions. I have function like: void perform(string method, ...) { // here I want to call method findMethod with _argptr and _arguments } MethodDesc findMethod(string method, ...) { // some lookup through the tables... } I know there are

Re: undefined reference to class template

2014-12-05 Thread Satoshi via Digitalmars-d-learn
I have defined LinkedList as di file, Im not compiling it. Im compiling every .d file separately, eg. main.d - main.d.o without including anything else. I tried to use -femit-templates but nothing happnes. I dont have object file of LinkedList.di, Im only importing it in source file and with

Re: undefined reference to class template

2014-11-22 Thread Satoshi via Digitalmars-d-learn
On Monday, 17 November 2014 at 21:12:54 UTC, Steven Schveighoffer wrote: On 11/14/14 6:29 PM, Satoshi wrote: Hi, Im using GDC 4.9.0 compiler. I have template classes like public class LinkedList(T) {...} and when I try compile it together, everything works fine. But when I compile every source

Re: undefined reference to class template

2014-11-17 Thread Satoshi via Digitalmars-d-learn
Could anyone help me please?

undefined reference to class template

2014-11-14 Thread Satoshi via Digitalmars-d-learn
Hi, Im using GDC 4.9.0 compiler. I have template classes like public class LinkedList(T) {...} and when I try compile it together, everything works fine. But when I compile every source file to separate object file and link it together with ld Ill get errors like: