Re: Fix template parameter

2022-08-10 Thread Nick Treleaven via Digitalmars-d-learn
On Wednesday, 10 August 2022 at 06:15:39 UTC, Dom Disc wrote: Ok, then I consider this is a bug in Phobos that should be corrected. All instances of ```D foo(T : fixedType)(T x) { } ``` should be replaced by ```D foo(fixedType x) { } ``` Perhaps, but not necessarily. The body of foo could

Re: Beta 2.099.0

2022-02-17 Thread Nick Treleaven via Digitalmars-d-announce
On Tuesday, 15 February 2022 at 13:06:47 UTC, Martin Nowak wrote: http://dlang.org/changelog/2.099.0.html Thanks. Regarding: https://dlang.org/changelog/2.099.0.html#allow_casting_from_typetuple_to_typetuple I don't understand why this is allowed: ```d alias Tuple(T...) = T; void foo() {

Re: Discussion Thread: DIP 1039--Static Arrays with Inferred Length--Community Review Round 1

2021-01-13 Thread Nick Treleaven via Digitalmars-d-announce
On Tuesday, 12 January 2021 at 17:27:50 UTC, Q. Schroll wrote: On Monday, 11 January 2021 at 21:17:20 UTC, jmh530 wrote: Gotcha. I think I would use that more than the current DIP (though I prefer [1]s to [1]$). You can do it today if you don't mind putting the marker in front:

Re: Discussion Thread: DIP 1039--Static Arrays with Inferred Length--Community Review Round 1

2021-01-13 Thread Nick Treleaven via Digitalmars-d-announce
On Monday, 11 January 2021 at 20:25:14 UTC, Luhrel wrote: I think if the DIP proposed a literal syntax instead of a new variable declaration syntax, it would be much less of a burden to the compiler. I think we don't have any partial (variable) type inference syntax ATM. I don't think that

Re: Discussion Thread: DIP 1039--Static Arrays with Inferred Length--Community Review Round 1

2021-01-13 Thread Nick Treleaven via Digitalmars-d-announce
On Wednesday, 13 January 2021 at 14:48:07 UTC, Atila Neves wrote: Why do they have to scroll to the top? They don't, you're right. But if you want to use it throughout the module you need a top-level import, by convention at the top. Also the convention seems to be to put a local import at

Re: Discussion Thread: DIP 1039--Static Arrays with Inferred Length--Community Review Round 1

2021-01-11 Thread Nick Treleaven via Digitalmars-d-announce
On Monday, 11 January 2021 at 13:05:18 UTC, jmh530 wrote: On Monday, 11 January 2021 at 12:32:42 UTC, Nick Treleaven wrote: [snip] I think if the DIP proposed a literal syntax instead of a new variable declaration syntax, it would be much less of a burden to the compiler. I think we don't

Re: Discussion Thread: DIP 1039--Static Arrays with Inferred Length--Community Review Round 1

2021-01-11 Thread Nick Treleaven via Digitalmars-d-announce
On Monday, 11 January 2021 at 12:32:42 UTC, Nick Treleaven wrote: ``` int[2] bar() { return [1,2]; } long[$] a6 = bar(); // implicit conversion static assert(is(typeof(a6) == long[2])); ``` Error: cannot implicitly convert expression `bar()` of type `int[2]` to `long[]` This is the error

Re: Discussion Thread: DIP 1039--Static Arrays with Inferred Length--Community Review Round 1

2021-01-11 Thread Nick Treleaven via Digitalmars-d-announce
On Friday, 8 January 2021 at 14:07:29 UTC, Luhrel wrote: Example a3 is straightforward the primary use case for staticArray: auto a3 = [1,2,3].staticArray; I really don't like the `.staticArray` because it's non-esthetic. I don't know if it's really argument, mainly because it's very

Re: Discussion Thread: DIP 1039--Static Arrays with Inferred Length--Community Review Round 1

2021-01-06 Thread Nick Treleaven via Digitalmars-d-announce
On Wednesday, 6 January 2021 at 18:33:54 UTC, Dukc wrote: ``` int[$] bar(int[2] arr) // Error: not allowed in functions declarations { return arr ~ [3, 4]; } ``` causes an error if the return type is specified as int[4]. Why? `arr` is static so the compiler should be able

Re: Discussion Thread: DIP 1039--Static Arrays with Inferred Length--Community Review Round 1

2021-01-06 Thread Nick Treleaven via Digitalmars-d-announce
On Wednesday, 6 January 2021 at 18:29:05 UTC, Nick Treleaven wrote: Can be fixed (probably with another name): //import std.array; Actually template overloading seems to work fine: template staticArray(T) { T[n] staticArray(ulong n) (auto ref T[n] a) {return a;} } T[n] staticArray(T,

Re: Discussion Thread: DIP 1039--Static Arrays with Inferred Length--Community Review Round 1

2021-01-06 Thread Nick Treleaven via Digitalmars-d-announce
On Wednesday, 6 January 2021 at 18:14:42 UTC, Luhrel wrote: It works only for the `int` type and above (and other types as structs). example with short: --- extern(C) void main() { import std.array; auto a = [0, 1].staticArray!short; // error } Can be fixed (probably with another

Re: Discussion Thread: DIP 1039--Static Arrays with Inferred Length--Community Review Round 1

2021-01-06 Thread Nick Treleaven via Digitalmars-d-announce
From the feedback thread: On Wednesday, 6 January 2021 at 17:54:34 UTC, Dukc wrote: `std.array.staticArray` can already handle most of the problems described, and it does work in betterC - I just tested with LDC 1.20.1 targeting WebAssembly. while there are remaining cases (`auto fun(int[$] =

Re: New language based on D

2020-11-25 Thread Nick Treleaven via Digitalmars-d-announce
On Wednesday, 18 November 2020 at 00:58:40 UTC, dangbinghoo wrote: both of them uses keyword `interface`, and "Interfaces describe a list of functions that a class that inherits from the interface must implement". shows these may not work with betterC. Pretty sure tardy only uses an

Re: From the D Blog: A Pattern for Head-mutable Structures

2020-07-03 Thread Nick Treleaven via Digitalmars-d-announce
On Thursday, 25 June 2020 at 13:17:55 UTC, jmh530 wrote: Good piece. I've been following the recent thread, but this really helped make some things clear. Do you have a link to that thread (or title) please?

Re: Beta 2.093.0

2020-07-03 Thread Nick Treleaven via Digitalmars-d-announce
On Wednesday, 24 June 2020 at 21:01:05 UTC, Martin Nowak wrote: http://dlang.org/changelog/2.093.0.html Thanks. BTW The list of bug fixes and enhancements seems to be missing.

Re: DIP 1028 "Make @safe the Default" is dead

2020-05-30 Thread Nick Treleaven via Digitalmars-d-announce
On Friday, 29 May 2020 at 21:18:13 UTC, Walter Bright wrote: On 5/29/2020 2:07 AM, Timon Gehr wrote: It would be great if `@safe:` did not affect declarations that would otherwise infer annotations. The idea is the simple, general rule that: attribute declaration; attribute {

Re: Why are immutable array literals heap allocated?

2019-07-06 Thread Nick Treleaven via Digitalmars-d-learn
On Friday, 5 July 2019 at 23:05:32 UTC, Jonathan M Davis wrote: Yes, I was wondering why the compiler doesn't statically allocate it automatically as an optimization. It would have to be set up to store the literal somewhere else. I was thinking the read-only data segment. Certainly, it

Re: Why are immutable array literals heap allocated?

2019-07-05 Thread Nick Treleaven via Digitalmars-d-learn
On Thursday, 4 July 2019 at 11:06:36 UTC, Eugene Wissner wrote: static immutable arr = [1, 2]; You have to spell it out that the data is static. Yes, I was wondering why the compiler doesn't statically allocate it automatically as an optimization.

Why are immutable array literals heap allocated?

2019-07-04 Thread Nick Treleaven via Digitalmars-d-learn
immutable(int[]) f() @nogc { return [1,2]; } onlineapp.d(2): Error: array literal in `@nogc` function `onlineapp.f` may cause a GC allocation This makes dynamic array literals unusable with @nogc, and adds to GC pressure for no reason. What code would break if dmd used only static data

Re: [TWiD] static foreach loop variable

2019-05-28 Thread Nick Treleaven via Digitalmars-d-learn
Ok, thanks for explaining. Nice idea.

Re: Create object from a library's Class returns Null

2019-05-28 Thread Nick Treleaven via Digitalmars-d-learn
On Tuesday, 28 May 2019 at 09:25:51 UTC, dangbinghoo wrote: class NSconf { String name; ... } Does this class have a non-default constructor?

Re: Create object from a library's Class returns Null

2019-05-28 Thread Nick Treleaven via Digitalmars-d-learn
On Tuesday, 28 May 2019 at 09:25:51 UTC, dangbinghoo wrote: writeln(Object.factory("gwlib.entity.nsconf.NSConf")); Typo, should be NSconf.

[TWiD] static foreach loop variable

2019-05-28 Thread Nick Treleaven via Digitalmars-d-learn
Hi, Last week's TWiD had a tip that didn't make sense: http://dpldocs.info/this-week-in-d/Blog.Posted_2019_05_20.html#tip-of-the-week template Locals(int i) { alias Whatever = int; } static foreach(i; [1, 2, 3]) { Locals!i.Whatever; } The body is just `int;`. Not sure how to reach Adam.

Re: now it's possible! printing floating point numbers at compile-time

2018-12-27 Thread Nick Treleaven via Digitalmars-d-announce
On Saturday, 22 December 2018 at 20:08:12 UTC, Stefan Koch wrote: I came across a short and efficient implementation[0] of the grisu2 algorithm for converting floating point numbers into strings. Which I then ported into CTFEable D code. Thus enabling you to convert doubles into strings at

Re: D Logic bug

2018-10-15 Thread Nick Treleaven via Digitalmars-d
On Thursday, 11 October 2018 at 23:17:15 UTC, Jonathan Marler wrote: For example, the "Conditional operator" in D actually has a higher priority than an assignment, but in C++ it's the same and is evaluated right-to-left. So this expression would be different in C++ and D: a ? b : c = d In

Re: Deep nesting vs early returns

2018-10-05 Thread Nick Treleaven via Digitalmars-d
On Thursday, 4 October 2018 at 06:43:02 UTC, Gopan wrote: I have seen people enclosing the function logic inside a while(1) merely to stick on to single return at the end. while(1) { ... break; //otherwise return would come here. ... break; } return ...; I

Re: DIP25/DIP1000: My thoughts round 2

2018-09-04 Thread Nick Treleaven via Digitalmars-d
Rust's lifetime syntax is noisy - the scope name is repeated, and why require a name if it's usually not given a meaningful one (`a`)? Rust is more limited semantically due to unique mutability, so it may have different requirements for function signatures to D. (I think they recently

Re: D is dead

2018-08-31 Thread Nick Treleaven via Digitalmars-d
On Thursday, 23 August 2018 at 09:09:40 UTC, Shachar Shemesh wrote: Please see the thread about lazy [1] for a case where a question actually has an answer, but nobody seems to know it I updated the spec for lazy parameters to add a link to lazy variadic functions at the end, and for the

Re: Friends don't let friends use inout with scope and -dip1000

2018-08-21 Thread Nick Treleaven via Digitalmars-d
On Tuesday, 21 August 2018 at 13:42:31 UTC, Kagamin wrote: int[] escape(scope int[] r) { return r; //error, can't return scoped argument } ... int[] escape(T)(scope int[] r) { return r; //ok! `scope` silently promoted to `return` } You can't have strictly scoped parameter in a

Re: Automatic variable declaration

2018-08-15 Thread Nick Treleaven via Digitalmars-d
On Wednesday, 15 August 2018 at 16:56:39 UTC, Everlast wrote: foo(int x = 3); foo(auto x = 3); If one has to declare the type it reduces it's effectiveness. auto is not a type ;-) Having e.g. auto or a type makes it clear that a new variable is being defined. I'd like this to work inside a

Re: Is there any hope for "lazy" and @nogc?

2018-08-05 Thread Nick Treleaven via Digitalmars-d
On Tuesday, 31 July 2018 at 20:03:39 UTC, ag0aep6g wrote: Looks like you can do it with a "lazy variadic function" [1], Interesting, thanks. I've made a pull to add a See Also link about this to the Lazy Parameters docs: https://github.com/dlang/dlang.org/pull/2439

Re: New edition of "The D Programming Language"?

2018-08-04 Thread Nick Treleaven via Digitalmars-d
On Friday, 3 August 2018 at 21:27:50 UTC, dlangPupil2 wrote: In lieu of a whole new edition maybe a web page listing major changes to D since Andrei's book came out might be useful (and help sales of his existing book too!!) https://wiki.dlang.org/Differences_With_TDPL

Re: Blogpost about the T.init problem

2018-07-23 Thread Nick Treleaven via Digitalmars-d-announce
On Wednesday, 11 July 2018 at 07:30:59 UTC, FeepingCreature wrote: To reproduce the format issue, try to print the struct with writefln!"%s"(MyDomainType()). I implemented the compile time format string checking by evaluating `format(fmtStr, Args.init)` at compile time and seeing if an

Re: Copy Constructor DIP

2018-07-11 Thread Nick Treleaven via Digitalmars-d
On Tuesday, 10 July 2018 at 10:47:04 UTC, RazvanN wrote: [1] https://github.com/dlang/DIPs/pull/129 Thanks for making the DIP. I can't get this code to compile (my struct has an `int i` field): static foreach (i, ref field; src.tupleof) this.tupleof[i] = field; Error: constant value

Re: Parenthesis around if/for/while condition is not necessary

2018-07-05 Thread Nick Treleaven via Digitalmars-d
On Wednesday, 4 July 2018 at 14:37:49 UTC, Timon Gehr wrote: if (a+b)*c == d { ... } Error: found `{` when expecting `;` following statement Adding the semi-colon, `*c == d;` would likely cause: Error: `*c == d` has no effect Also multiplying (a+b) by a pointer is illegal, and c is probably

Re: Compilation is taking a ton of memory

2018-07-01 Thread Nick Treleaven via Digitalmars-d
On Wednesday, 27 June 2018 at 16:00:37 UTC, Mario Silva wrote: Less than an year ago our project was taking around 17 seconds to compile - no libs requiring compilation - and maybe around 50 seconds for full compilation, and it now takes around 50 seconds for an incremental compilations and

Re: Parenthesis around if/for/while condition is not necessary

2018-07-01 Thread Nick Treleaven via Digitalmars-d
On Sunday, 24 June 2018 at 23:40:56 UTC, Timoses wrote: The others may be rewritten to not have a leading "!" as well, e.g. if (!(t1.ty == Tarray && t2.ty == Tarray && needsDirectEq(t1, t2)) if (t1.ty != Tarray || t2.ty != Tarray || ...) Yes, but you might make a mistake, and sometimes it

Re: Morale of a story: ~ is the right choice for concat operator

2018-05-26 Thread Nick Treleaven via Digitalmars-d
On Friday, 25 May 2018 at 08:27:30 UTC, Dukc wrote: If you add two characters, it interprets it as a concatenation that results in a string with two charactes. ... Now, if I were programming in D, this would not have happened. Using + always means an addition. I don't think it makes sense to

Re: Extend the call site default argument expansion mechanism?

2018-05-16 Thread Nick Treleaven via Digitalmars-d
On Tuesday, 15 May 2018 at 15:02:36 UTC, jmh530 wrote: auto opDispatch(string s)() if (s == "bar") In case anyone isn't aware, this is better written: auto opDispatch(string s : "bar")()

Identifier from string - Re: static foreach considered

2018-05-14 Thread Nick Treleaven via Digitalmars-d
On Monday, 8 June 2015 at 21:32:52 UTC, Timon Gehr wrote: On 06/08/2015 10:16 PM, Idan Arye wrote: It would be nice together with this feature to be able to mixin identifiers: static foreach (ident; ["foo", "bar"]) { auto mixin(ident)() { // code for

Re: Bug?: Presence of "init()" Method Causes std.array.appender to Fail to Compile

2018-05-14 Thread Nick Treleaven via Digitalmars-d
On Monday, 14 May 2018 at 01:20:38 UTC, Jonathan M Davis wrote: Yeah. It's been discussed that it should be illegal to declare a struct or class member named init, but that change has yet to happen. https://issues.dlang.org/show_bug.cgi?id=7066 Walter and Timon have considered redefinition

Re: Is there a strong reason for Nullable's alias get this?

2018-04-21 Thread Nick Treleaven via Digitalmars-d
On Wednesday, 18 April 2018 at 13:36:15 UTC, FeepingCreature wrote: That said, I'm pretty sure that get will throw anyways if invoked without a default value. Not in release mode, but I suppose that doesn't matter. I've made a pull to update the docs to reflect this:

Re: Feature to get or add value to an associative array.

2018-04-20 Thread Nick Treleaven via Digitalmars-d
On Wednesday, 18 April 2018 at 16:04:13 UTC, Giles Bathgate wrote: I understand where you are coming from, but I am not sure it is appropriate to shoehorn every use case into one api. It is not shoehorning, the difference here is just returning by ref vs pointer. I understand that, as the

Re: Feature to get or add value to an associative array.

2018-04-20 Thread Nick Treleaven via Digitalmars-d
On Wednesday, 18 April 2018 at 16:47:50 UTC, ag0aep6g wrote: You can get a pointer from the ref return: Value* p = ("key", { inserted = true; return Value.init; }); This is not @safe, even with -dip1000: Error: cannot take address of ref return of f() in @safe function main

Re: Is there a strong reason for Nullable's alias get this?

2018-04-18 Thread Nick Treleaven via Digitalmars-d
On Wednesday, 18 April 2018 at 08:24:14 UTC, FeepingCreature wrote: If nobody objects, I'll make a PR to deprecate it. +1. Nullable has received some improvements lately, it would be great if `get` was no longer implicit. For new code, it is trivial to write `.get` to convert to the original

Re: Feature to get or add value to an associative array.

2018-04-18 Thread Nick Treleaven via Digitalmars-d
On Tuesday, 17 April 2018 at 20:49:30 UTC, Steven Schveighoffer wrote: Why do you think it's less efficient to use a lazy parameter? Wouldn't an extra function call have to happen, at least in some cases? This pattern needs a pointer to be returned, instead of using `ref`. Note that `` is

Re: Feature to get or add value to an associative array.

2018-04-17 Thread Nick Treleaven via Digitalmars-d
On Sunday, 15 April 2018 at 22:52:47 UTC, Giles Bathgate wrote: The function provides a means to get a value corresponding to the key, but if the value doesn't exist it will evaluate the lazy argument to create a new value, add this to the associative array and then return it. auto p =

Re: Escaping address of

2018-04-12 Thread Nick Treleaven via Digitalmars-d-learn
On Thursday, 12 April 2018 at 00:32:49 UTC, Uknown wrote: Adding a destructor makes the compiler return an error about lifetimes, with or without -dip1000 Thanks. Filed, mentioning this: https://issues.dlang.org/show_bug.cgi?id=18756

Escaping address of

2018-04-11 Thread Nick Treleaven via Digitalmars-d-learn
Is this a known bug? With v2.079.0, with or without -dip1000: @safe unittest { struct S { int i; } auto p = ().i; } The address of field `i` should not escape, right? It's also incorrectly allowed when using an lvalue of S (when -dip1000 is not present).

Re: Deprecating this(this)

2018-04-11 Thread Nick Treleaven via Digitalmars-d
On Thursday, 5 April 2018 at 18:46:25 UTC, H. S. Teoh wrote: I like this idea. Except the syntax could be improved: this(this orig) // <-- N.B. { It's already valid syntax, equivalent to `this(typeof(this) orig)`. It can be called explicitly, but is ignored for

Re: rvalues -> ref (yup... again!)

2018-03-29 Thread Nick Treleaven via Digitalmars-d
On Saturday, 24 March 2018 at 17:34:09 UTC, Manu wrote: You mutate a temporary that times out at the end of the statement... your statement is never assigned to anything, and has no effect. That is solved by having the ref function return its argument (so it can be chained): struct S; ref

Re: how to make private class member private

2018-03-29 Thread Nick Treleaven via Digitalmars-d-learn
On Sunday, 18 March 2018 at 18:45:23 UTC, Steven Schveighoffer wrote: unittest { auto foo = new Foo; assert(foo.internalbuffer.empty); // note, this is a private symbol. } I don't understand why you would want a private symbol in a *documented* unittest, the reader of the

[OT] - Re: Could someone take a look at DIP PR 109?

2018-03-28 Thread Nick Treleaven via Digitalmars-d
On Wednesday, 28 March 2018 at 06:43:15 UTC, Shachar Shemesh wrote: For those too lazy to click on the link, BTW It's not the reader's 'laziness', it's basic courtesy on the part of the poster to the newsgroup to provide a meaningful subject line for a thread. Far more people will read the

Re: how to make private class member private

2018-03-17 Thread Nick Treleaven via Digitalmars-d-learn
On Tuesday, 13 March 2018 at 13:59:00 UTC, Steven Schveighoffer wrote: If you limit to class members, then you have to do something like C++ friends, which are unnecessarily verbose. Not if you also have a module-level visibility modifier, which could have been `module`. IMO, the

Re: how to make private class member private

2018-03-17 Thread Nick Treleaven via Digitalmars-d-learn
On Tuesday, 13 March 2018 at 05:11:48 UTC, psychoticRabbit wrote: If you have access to the module source, you have access to the source of types inside it. Making the module the lowest level of encapsulation makes sense from that perspective. There are two problems I see: 1st - D has broken

Re: Tuple DIP

2018-03-15 Thread Nick Treleaven via Digitalmars-d
On Wednesday, 17 January 2018 at 06:44:21 UTC, Timon Gehr wrote: It uses tuples because it uses zip. The code does not compile today, because the lambda I'm passing to "map" has two parameters: auto a = [1, 2, 4, 7, 2]; auto b = [3, 5, 3, 2, 4]; // auto c = zip(a, b).map!((x, y) => x + y);

Re: rvalue types

2018-03-12 Thread Nick Treleaven via Digitalmars-d
On Monday, 12 March 2018 at 16:51:06 UTC, H. S. Teoh wrote: For example, today you can already make opBinary() return something other than the parent type, and use alias this to make it decay to the parent type. Sounds like this: https://en.wikipedia.org/wiki/Expression_templates

Re: C++ launched its community survey, too

2018-03-07 Thread Nick Treleaven via Digitalmars-d
On Wednesday, 28 February 2018 at 20:01:34 UTC, H. S. Teoh wrote: As Andrei wrote in TDPL, (and I paraphrase,) it sucks when built-in types have magical abilities inaccessible to user code. This is a common defect in many programming languages... the "magical" behaviour is wonderful when it

Re: Why not flag away the mistakes of the past?

2018-03-07 Thread Nick Treleaven via Digitalmars-d
On Wednesday, 7 March 2018 at 13:24:25 UTC, Jonathan M Davis wrote: I'd actually argue that that's the lesser of the problems with auto-decoding. The big problem is that it's auto-decoding. Code points are almost always the wrong level to be operating at. For me the fundamental problem is

Re: implicit construction operator

2018-03-02 Thread Nick Treleaven via Digitalmars-d
On Monday, 26 February 2018 at 21:07:52 UTC, Meta wrote: This is possible in the language today using the implicit class construction feature of runtime variadic arrays: class VArray { Variant[] va; this(T...)(T ts) { foreach(t; ts) { va ~= Variant(t); } } } void test(VArray ta...)

Re: implicit construction operator

2018-02-28 Thread Nick Treleaven via Digitalmars-d
On Monday, 26 February 2018 at 21:36:49 UTC, ketmar wrote: aliak wrote: It makes libraries *much* more intuitive and expressive (C++ just got it wrong by choosing the wrong default). If you allow library authors to opt in instead of opt out then it becomes a conscious decision for one.

[OT] - Re: Workaround for https://issues.dlang.org/show_bug.cgi?id=18422?

2018-02-13 Thread Nick Treleaven via Digitalmars-d
On Sunday, 11 February 2018 at 15:34:07 UTC, Andrei Alexandrescu wrote: I'm trying to sketch a simple compile-time reflection system, and https://issues.dlang.org/show_bug.cgi?id=18422 is a blocker of the entire approach. BTW please write a descriptive subject, not a bug ID. The #dbugfix

Re: ExpressionTuple is referenced in the specs, but doesn't seem to be defined

2018-02-02 Thread Nick Treleaven via Digitalmars-d
On Wednesday, 31 January 2018 at 12:35:37 UTC, Nick Treleaven wrote: It's now called an Expression List: https://dlang.org/ctarguments.html#homogenous-lists That page needs an update too, we should call them sequences. I'll try to update the docs soon. There are still various places that

Re: The daily D riddle - this parameter

2018-02-01 Thread Nick Treleaven via Digitalmars-d
On Sunday, 28 January 2018 at 06:44:28 UTC, Timothee Cour wrote: likewise the following compiles, but IMO should not: class A{ void fun(this a){}} (instead we should have typeof(this) Yes, it's also confusing reading it, I thought it was template this for a second. It even works if fun is

Re: ExpressionTuple is referenced in the specs, but doesn't seem to be defined

2018-01-31 Thread Nick Treleaven via Digitalmars-d
On Friday, 26 January 2018 at 19:44:21 UTC, Dechcaudron wrote: See, for instance, definition https://dlang.org/spec/class.html#class_properties. If it is defined anywhere, I cannot seem to find it. It's now called an Expression List: https://dlang.org/ctarguments.html#homogenous-lists I'll

Re: The most confusing error message

2018-01-24 Thread Nick Treleaven via Digitalmars-d
On Wednesday, 24 January 2018 at 14:22:59 UTC, Meta wrote: One way we could probably improve the error message is to change it to "template struct test.A(int var = 3) is used as a type. It must be instantiated", or something along those lines, to make it clear why you can't use A as a type.

Re: Implementing tail-const in D

2018-01-24 Thread Nick Treleaven via Digitalmars-d
On Tuesday, 23 January 2018 at 09:36:03 UTC, Simen Kjærås wrote: Unqual is the standard way today to get a head-mutable version of something. For dynamic arrays, static arrays, pointers and value types, including structs without aliasing, thi works. For AAs, classes, and structs with aliasing,

Re: Some thoughts about C and D, return data through parameters

2017-12-21 Thread Nick Treleaven via Digitalmars-d
On Tuesday, 19 December 2017 at 08:54:38 UTC, Petar Kirov [ZombineDev] wrote: Reminds me of C#7's out variable declarations: https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-7#out-variables However multiple return values are much better implemented through language-integrated

Re: Maybe D is right about GC after all !

2017-12-21 Thread Nick Treleaven via Digitalmars-d
On Tuesday, 19 December 2017 at 11:30:14 UTC, ketmar wrote: but Rikki, we have this! i'm using refcounted structs for years, and it works like a charm! ;-) You can either have guaranteed memory-safe (due to DIP1000) but inefficient RC (due to extra runtime checks*), or efficient and not

Re: building git druntime - range violation in extendedPathThen

2017-12-07 Thread Nick Treleaven via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 17:11:49 UTC, Nick Treleaven wrote: 0x005482C2 in nothrow void* ddmd.root.filename.extendedPathThen!(ddmd.root.file.File.read().__lambda1).extendedPathThen(const(char*)) at C:\git\dmd\src\ddmd\root\filename.d(834) 0x005480E8 in File at

Re: Does dmd not always compile all of the source code?

2017-12-06 Thread Nick Treleaven via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 17:04:06 UTC, A Guy With a Question wrote: abstract class Test(T) Here you have a class template. It does produce there error when I do this: class Test2 : Test!int You instantiated the template, so the compiler can now type check the instantiated

building git druntime - range violation in extendedPathThen

2017-12-06 Thread Nick Treleaven via Digitalmars-d-learn
Hi, I checked out dmd and druntime this morning. dmd seems to build fine, but when I try druntime I get this error: $ make -f win32.mak ..\dmd\generated\windows\release\32\dmd -conf= -c -o- -Isrc -Iimport -Hfimport\core\sync\barrier.di src\core\sync\barrier.d DMD v2.077.1 DEBUG

Re: Inference of Scoped Destruction

2017-12-04 Thread Nick Treleaven via Digitalmars-d
On Thursday, 30 November 2017 at 16:31:25 UTC, Nordlöw wrote: How would this interact with explicit scope-qualification of `x`? That would allow the compiler to avoid GC allocation for x. It seems essentially the same case as Walter describes here:

Re: Andrei's "The D Programming Language" book. Up to date?

2017-11-29 Thread Nick Treleaven via Digitalmars-d-learn
On Wednesday, 29 November 2017 at 17:50:59 UTC, Arun Chandrasekaran wrote: Multiple alias this You can only have one subtyping member currently. Shared Not all of shared's guarantees are implemented yet. SafeD @safe (and therefore SafeD) isn't fully implemented. So, it doesn't necessarily

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-29 Thread Nick Treleaven via Digitalmars-d
On Sunday, 19 November 2017 at 22:54:38 UTC, Walter Bright wrote: I can't see the problem. You go from nullable to non-nullable by checking for null, and the other direction happens implicitly. Implicit conversions have their problems with overloading, The C# implementation doesn't affect

Re: Andrei's "The D Programming Language" book. Up to date?

2017-11-29 Thread Nick Treleaven via Digitalmars-d-learn
On Wednesday, 4 October 2017 at 20:49:26 UTC, John Gabriele wrote: What's changed in the language, library, and community since then that I should be aware of if following along with and learning from that book? Here's a list of significant things - maybe incomplete:

[OT] Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-24 Thread Nick Treleaven via Digitalmars-d
On Thursday, 23 November 2017 at 06:35:17 UTC, codephantom wrote: I love not being able to edit posts. It's so convenient. It's not as much of a problem as not being able to hide all posts by a user who repeats arguments, derails the conversation onto irrelevant side discussions and judges

Re: "body" keyword is unnecessary

2017-11-21 Thread Nick Treleaven via Digitalmars-d
On Sunday, 19 November 2017 at 11:54:04 UTC, Tony wrote: dmd --version DMD64 D Compiler v2.077.0 Copyright (c) 1999-2017 by Digital Mars written by Walter Bright dmd test_contracts.d test_contracts.d(13): Error: missing `body { ... }` after `in` or `out` Just made a pull to fix this:

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-20 Thread Nick Treleaven via Digitalmars-d
On Sunday, 19 November 2017 at 22:54:38 UTC, Walter Bright wrote: There's also an issue of how to derive a class from a base class. If you want null, use a nullable type: Base b = ...; Derived? d = cast(Derived?) base; if (d !is null) d.method; This implies one must know all the use cases of

Re: RAII in betterC

2017-11-20 Thread Nick Treleaven via Digitalmars-d
On Monday, 20 November 2017 at 17:13:37 UTC, Oleg B wrote: Hello. I know about some implementation issues http://forum.dlang.org/thread/nqctbzhrdldmnffch...@forum.dlang.org What work must be done for fix it? For what time is it scheduled? Looks like Walter is working on it:

Re: Deprecate implicit `int` to `bool` conversion for integer literals

2017-11-14 Thread Nick Treleaven via Digitalmars-d
On Tuesday, 14 November 2017 at 13:43:32 UTC, Michael V. Franklin wrote: Nick, if it's not in bugzilla already, can you please add it? Sure: https://issues.dlang.org/show_bug.cgi?id=17983

Re: Deprecate implicit `int` to `bool` conversion for integer literals

2017-11-14 Thread Nick Treleaven via Digitalmars-d
On Sunday, 12 November 2017 at 16:57:05 UTC, Andrei Alexandrescu wrote: The overload being called depends on (a) whether a - b can be computed during compilation or not, and (b) the actual value of a - b. Clearly a big problem for modular code. This is the smoking gun motivating the DIP. An

Re: Project Elvis

2017-11-13 Thread Nick Treleaven via Digitalmars-d
On Tuesday, 7 November 2017 at 13:43:20 UTC, user1234 wrote: On Monday, 6 November 2017 at 20:14:17 UTC, Meta wrote: The functionality is probably a good idea, but a library solution is doable today without any acrobatics. Show me a library solution that works fine with IDE completion (so

Re: Project Elvis

2017-11-13 Thread Nick Treleaven via Digitalmars-d
On Saturday, 11 November 2017 at 05:20:39 UTC, codephantom wrote: I just saw this about the new 'damnit' operator, for C# 8. https://github.com/dotnet/csharplang/issues/556 The principle is a good one - by default you cannot dereference something that can be null, you get a compiler error

Re: Project Elvis

2017-11-13 Thread Nick Treleaven via Digitalmars-d
On Monday, 6 November 2017 at 13:02:43 UTC, Ola Fosheim Grøstad wrote: On Monday, 6 November 2017 at 10:12:11 UTC, Jonathan M Davis wrote: All it does is take the expression x ? x : y and make it x ?: y Yes, that is an issue because it means that typos no longer are caught. E.g. if you

switch - Re: Improve "Improve Contract Syntax" DIP 1009

2017-11-06 Thread Nick Treleaven via Digitalmars-d
On Thursday, 2 November 2017 at 20:37:11 UTC, user1234 wrote: switch (i) default: break; } you have 3 non-ambiguous and contiguous statements without a block: a switch, a default case (the "free-floating" one) and a break. Now why is this allowed is another story ;) I've found a

Re: Improve "Improve Contract Syntax" DIP 1009

2017-11-04 Thread Nick Treleaven via Digitalmars-d
On Saturday, 4 November 2017 at 06:08:22 UTC, Jonathan M Davis wrote: Heck, take a really simply one like sqrt. All you have to check in the out contract is the return value. You have no idea what was passed in. So, how would you write an out contract verifying that you got the correct number?

Re: Improve "Improve Contract Syntax" DIP 1009

2017-11-03 Thread Nick Treleaven via Digitalmars-d
On Friday, 3 November 2017 at 02:32:41 UTC, Jonathan M Davis wrote: Personally, I hate how verbose they are, but my solution is just not to use them. And IMHO, the only place that they add real value is in classes, where their success or failure can be & or ||ed based on how that should work

Re: Project Elvis

2017-11-02 Thread Nick Treleaven via Digitalmars-d
On Saturday, 28 October 2017 at 11:38:52 UTC, Andrei Alexandrescu wrote: Walter and I decided to kick-off project Elvis for adding the homonym operator to D. I'd like to mention null-coalescing assignment syntax. Perl has `$a //= $b`, and PHP has voted to support `$a ??= $b`, expanding to

Re: Editor recommendations for new users.

2017-08-30 Thread Nick Treleaven via Digitalmars-d
On Sunday, 27 August 2017 at 10:28:29 UTC, Dukc wrote: The problem with geany is that it's syntax highlighting and auto-completion depend on having the file where the symbol's defined open. No, Geany supports generation and automatic loading of global tags files:

Re: DIP 1009--Improve Contract Usability--Preliminary Review Round 2 Begins

2017-07-31 Thread Nick Treleaven via Digitalmars-d
On Friday, 28 July 2017 at 16:58:41 UTC, Moritz Maxeiner wrote: Having a keyword delimit the end of an optional is both redundant and inconsistent You are arguing against the current syntax, not my proposal. In my case the `do` keyword would be disambiguating between out expressions and out

Re: DIP 1009--Improve Contract Usability--Preliminary Review Round 2 Begins

2017-07-31 Thread Nick Treleaven via Digitalmars-d
On Friday, 28 July 2017 at 16:44:24 UTC, MysticZach wrote: On Friday, 28 July 2017 at 11:04:23 UTC, Nick Treleaven wrote: One option to solve the out contract ambiguity and aid parsing by tools is to require 'do' after out contract expressions. BTW `do` would only be required before the {}

Re: DIP 1012--Attributes--Preliminary Review Round 1

2017-07-28 Thread Nick Treleaven via Digitalmars-d
On Friday, 28 July 2017 at 01:50:24 UTC, Jonathan M Davis wrote: Should public have @ on it? Should static have @ on it? What about scope, const, or shared? If they are storage classes, they shouldn't have @. If they are statement or expression keywords, they shouldn't have @. Things like

Re: DIP 1009--Improve Contract Usability--Preliminary Review Round 2 Begins

2017-07-28 Thread Nick Treleaven via Digitalmars-d
On Friday, 21 July 2017 at 13:51:05 UTC, Mike Parker wrote: DIP 1009 is titled "Improve Contract Usability". https://github.com/dlang/DIPs/blob/master/DIPs/DIP1009.md I think the proposed in/out expression contracts should require pure expressions. In the rare case that impurity is required,

Re: New Garbage Collector?

2017-07-25 Thread Nick Treleaven via Digitalmars-d
On Saturday, 22 July 2017 at 10:17:49 UTC, Temtaime wrote: The new precise GC will be never added to druntime. 2.075 has precise scanning of the DATA and the TLS segments (on Windows): http://dlang.org/spec/garbage.html#precise_dataseg This seems like significant progress towards precise

Re: If Statement with Declaration

2017-07-24 Thread Nick Treleaven via Digitalmars-d
On Monday, 24 July 2017 at 13:12:17 UTC, Nick Treleaven wrote: static if (is(E == enum; alias V)) { // this inserts "V" V v; } The test comes first as it logically should, as the alias is not being used until the following statement. Hmm, it can be used in the test: is(Abc U : U*) is(AA

Re: If Statement with Declaration

2017-07-24 Thread Nick Treleaven via Digitalmars-d
On Monday, 24 July 2017 at 13:12:17 UTC, Nick Treleaven wrote: On Friday, 21 July 2017 at 21:50:02 UTC, Johan Engelen wrote: static if (is(E V == enum)) { // this inserts "V" V v; } ``` Yes, but this is a bit different as the goal is to avoid repeating V Sigh. Repeating E.

Re: If Statement with Declaration

2017-07-24 Thread Nick Treleaven via Digitalmars-d
On Friday, 21 July 2017 at 21:50:02 UTC, Johan Engelen wrote: We do have a construct like that already: ``` static if (is(E V == enum)) { // this inserts "V" V v; } ``` Yes, but this is a bit different as the goal is to avoid repeating V (as it may be complex). Repeating a local variable

Re: The X Macro using D

2017-07-21 Thread Nick Treleaven via Digitalmars-d
On Friday, 21 July 2017 at 11:19:47 UTC, Patrick Schluter wrote: In C there's no point in the X macro anymore since C99. Designated initializer allow to do it properly[1] now. enum COLORS { red, blue, green, max }; char *cstring[max] = {[red]="red", [blue]="blue", [green]="green" };

Re: Error in spec: struct init with member names

2017-07-04 Thread Nick Treleaven via Digitalmars-d
On Monday, 3 July 2017 at 18:14:43 UTC, Johan Engelen wrote: The spec (or DMD frontend) is broken regarding struct initialization with explicit mention of member field names: https://dlang.org/spec/struct.html#static_struct_init I agree, PR: https://github.com/dlang/dlang.org/pull/1794

<    1   2   3   4   5   >