2 class issues

2019-03-07 Thread spir via Digitalmars-d-learn
Hello, First, I am not very experimented with the combination of static lang (alloc & typing) and OO (class-based). I'm implementing a library for lexical analysis (lexing), with 2 minor issues: -1- How to enforce that subclasses implement given methods without using "abstract", which seems

Re: 2 class issues -- PS

2019-03-07 Thread spir via Digitalmars-d-learn
from [https://dlang.org/spec/attribute.html#abstract] : --- abstract Attribute An abstract member function must be overridden by a derived class. Only virtual member functions may be declared abstract; non-virtual member functions and free-standing functions cannot be declared abstract

Re: this is null

2019-03-10 Thread spir via Digitalmars-d-learn
On 09/03/2019 21:10, ANtlord via Digitalmars-d-learn wrote: On Saturday, 9 March 2019 at 20:04:53 UTC, Paul Backus wrote: You can end up with a null `this` reference if you dereference a null pointer to a struct and then call a method on the result. For example: I can but my reference is n

Re: Distinguish float and integer types from string

2019-03-10 Thread spir via Digitalmars-d-learn
On 09/03/2019 19:11, Jacob Shtokolov via Digitalmars-d-learn wrote: The thing is that in PHP, for example, I would do The thing is php needs to be able to "lexify" raw input data at runtime, while in D this is done at compile-time. The ompiler has the lexer to do that. But I agree that, for

Re: Why does D language do not support BigDecimal type?

2019-03-12 Thread spir via Digitalmars-d-learn
On 12/03/2019 10:31, Boqsc via Digitalmars-d-learn wrote: Please attach quick working examples for every sentence you write or it's just a waste of time. People want to see the results and direct actions first before anything else, it's more efficient communication. We are in the subforum of Dl

local class instance (at module-level)

2019-03-14 Thread spir via Digitalmars-d-learn
I desperately try to declare/define/initialise a simple class instance at module-level. This is a special (conceptually static and immutable) instance used as a "marker", that just should exist and be accessible by methods of this class and/or other classes defined in the same module. (Thus I do

bug in doc?

2019-03-14 Thread spir via Digitalmars-d-learn
https://dlang.org/spec/hash-map.html#static_initialization: immutable long[string] aa = [ "foo": 5, "bar": 10, "baz": 2000 ]; ==> Error: non-constant expression `["foo":5L, "bar":10L, "baz":2000L]` Also: I don't understand the error message: * What is non-constant in the *expression*? * A

Re: local class instance (at module-level)

2019-03-14 Thread spir via Digitalmars-d-learn
On 14/03/2019 12:16, H. S. Teoh via Digitalmars-d-learn wrote: On Thu, Mar 14, 2019 at 12:05:22PM +0100, spir via Digitalmars-d-learn wrote: I desperately try to declare/define/initialise a simple class instance at module-level. This is a special (conceptually static and immutable) instance

Re: bug in doc?

2019-03-14 Thread spir via Digitalmars-d-learn
On 14/03/2019 15:52, H. S. Teoh via Digitalmars-d-learn wrote: On Thu, Mar 14, 2019 at 03:22:52PM +0100, spir via Digitalmars-d-learn wrote: https://dlang.org/spec/hash-map.html#static_initialization: immutable long[string] aa = [ "foo": 5, "bar": 10, "baz&

Re: local class instance (at module-level)

2019-03-14 Thread spir via Digitalmars-d-learn
On 15/03/2019 00:45, ag0aep6g via Digitalmars-d-learn wrote: On 14.03.19 20:43, Jacob Carlborg wrote: class C { uint i ; this (uint i) { this.i = i ; } this (uint i) shared { this.i = i ; } this (uint i) immutable { this.i = i ; } }

Re: Can't make inout work.

2019-03-16 Thread spir via Digitalmars-d-learn
On 16/03/2019 04:49, Paul Backus via Digitalmars-d-learn wrote: On Friday, 15 March 2019 at 23:57:15 UTC, aliak wrote: Anyone knows how to make this work? You need an explicit `inout` on the return value of `make`: auto ref make(T)(inout auto ref T value) {     return inout(S!T)(value); }

Re: Can't make inout work.

2019-03-16 Thread spir via Digitalmars-d-learn
PS: the chapter of Ali Çehreli's book on func args is great: http://ddili.org/ders/d.en/function_parameters.html diniz

Re: Block statements and memory management

2019-03-16 Thread spir via Digitalmars-d-learn
On 16/03/2019 11:19, Dennis via Digitalmars-d-learn wrote: On Saturday, 16 March 2019 at 03:47:43 UTC, Murilo wrote: Does anyone know if when I create a variable inside a scope as in {int a = 10;} it disappears complete from the memory when the scope finishes? Or does it remain in some part of

Re: Can't make inout work.

2019-03-18 Thread spir via Digitalmars-d-learn
On 17/03/2019 18:34, Kagamin via Digitalmars-d-learn wrote: On Saturday, 16 March 2019 at 14:57:35 UTC, Paul Backus wrote: This code fails to compile if you change `auto s2` to `const s2`--in other words, it has the same problem as the original example. Maybe there's not much need for qualifie

Re: How to check i

2014-10-16 Thread spir via Digitalmars-d-learn
On 16/10/14 20:46, Uranuz via Digitalmars-d-learn wrote: I have some string *str* of unicode characters. The question is how to check if I have valid unicode code point starting at code unit *index*? [...] You cannot do that without decoding. Cheking whether utf-x is valid and decoding are the

Re: Beginner ?. Why does D suggest to learn java

2014-10-17 Thread spir via Digitalmars-d-learn
On 17/10/14 07:38, maarten van damme via Digitalmars-d-learn wrote: While d can be complex, there's nothing preventing you from starting out simple and not using all features at first. I don't understand why it's not suitable for a beginner if you use this approach... For some reasons, in my vi

Re: Beginner ?. Why does D suggest to learn java

2014-10-17 Thread spir via Digitalmars-d-learn
On 17/10/14 03:05, ketmar via Digitalmars-d-learn wrote: On Fri, 17 Oct 2014 00:52:14 + MachineCode via Digitalmars-d-learn wrote: I don't understand. If at least it were C but java? why not D itself? C is *awful* as "beginner's language". never ever let people start with C if you don't h

Re: String created from buffer has wrong length and strip() result is incorrect

2014-10-17 Thread spir via Digitalmars-d-learn
On 17/10/14 09:29, thedeemon via Digitalmars-d-learn wrote: On Friday, 17 October 2014 at 06:29:24 UTC, Lucas Burson wrote: // This is where things breaks { ubyte[] buff = new ubyte[16]; buff[0..ATA_STR.length] = cast(ubyte[])(ATA_STR); // read the string back from the