Re: Library Typedefs are fundamentally broken

2014-09-17 Thread Jack Applegame via Digitalmars-d
You can use module name and line number as unique tag.

Re: D in my trashbin

2014-10-24 Thread Jack Applegame via Digitalmars-d
On Friday, 24 October 2014 at 02:42:13 UTC, frustrated wrote: Two days later and I still cant get a 'Hello World' to compile. It is far beyond me how a project can exist for so many years and still not have a straightforward installation that works out of the box. Yes.. read the forums and

Re: Which D IDE do you use?(survey)

2015-04-08 Thread Jack Applegame via Digitalmars-d
Sublime Text 3

Re: Polymorphic recursive class

2015-07-13 Thread Jack Applegame via Digitalmars-d
On Monday, 13 July 2015 at 10:33:17 UTC, Dmitry Olshansky wrote: You might mean Nested!A[] ? No. Else it looks like making a construct that is: left - an element, right - { left - an array, right - { left - an array of arrays, right - { left- an

Re: Polymorphic recursive class

2015-07-13 Thread Jack Applegame via Digitalmars-d
On Monday, 13 July 2015 at 09:03:20 UTC, deadalnix wrote: Just use static if and be done with it. How?

Re: Polymorphic recursive class

2015-07-13 Thread Jack Applegame via Digitalmars-d
On Monday, 13 July 2015 at 12:53:12 UTC, deadalnix wrote: On Monday, 13 July 2015 at 11:36:48 UTC, Jack Applegame wrote: Yes, that is I intended. It is a pretty useless example, just for demonstrating the lack of support polymorphic recursive data types. So the point is that we should add

Re: Polymorphic recursive class

2015-07-13 Thread Jack Applegame via Digitalmars-d
Yes! It works: http://dpaste.dzfl.pl/b9c6a2a958e5

Re: Polymorphic recursive class

2015-07-13 Thread Jack Applegame via Digitalmars-d
On Monday, 13 July 2015 at 13:51:51 UTC, Dmitry Olshansky wrote: You can do it no problem, it just requires to manually implement boxing and make `right` a template that casts to the right type. The reason is that D doesn't provide an extra abstraction layer that is auto-magically there in

Polymorphic recursive class

2015-07-13 Thread Jack Applegame via Digitalmars-d
This code doesn't compile, because recursive template expansion. class Nested(A) { A left; Nested!(A[]) right; this(A l, Nested!(A[]) r) { left = l; right = r; } } void main() { Nested!int nested = new Nested(1, null); } But it successfully compiles in Java an C#. And

Re: Polymorphic recursive class

2015-07-13 Thread Jack Applegame via Digitalmars-d
On Monday, 13 July 2015 at 08:05:05 UTC, thedeemon wrote: On Monday, 13 July 2015 at 06:31:33 UTC, Jack Applegame wrote: But is there any reason why D can't follow MLton way - instantiate a class type template ONLY when a constructor of given class is used? Because if constructor isn't used

Re: opDispatch and compile time parameters

2015-10-19 Thread Jack Applegame via Digitalmars-d
D template system is very powerful. This is more generic solution: import std.stdio; class B { auto p1(T)(T arg) { writeln( "p1: ", arg ); } auto p2(T, int C)(T s) { writeln( "p2: ", s, " / ", C); } } class C(T) { T b = new T; template opDispatch(string s) { template

Re: opDispatch and compile time parameters

2015-10-19 Thread Jack Applegame via Digitalmars-d
On Monday, 19 October 2015 at 17:50:02 UTC, Nikolay wrote: On Monday, 19 October 2015 at 08:41:46 UTC, Jack Applegame wrote: D template system is very powerful. This is more generic solution: http://dpaste.dzfl.pl/791c65d0e4ee Wow! I can't believe that it is possible and there is so

Re: I hate new DUB config format

2015-11-26 Thread Jack Applegame via Digitalmars-d
On Thursday, 26 November 2015 at 09:41:38 UTC, ponce wrote: On Thursday, 26 November 2015 at 09:04:27 UTC, Ilya Yaroshenko wrote: Single language, json based configuration engine is simpler for IDE development and configuration tools. For example, Sublime Text.This is very important to make

Re: Make D language as Apache foundation project

2016-07-28 Thread Jack Applegame via Digitalmars-d
On Wednesday, 27 July 2016 at 15:44:21 UTC, Seb wrote: http://dlang.org/foundation.html Wow. This page details Andrei's full name: Tudor Andrei Cristian Alexandrescu. (o_O)

Re: Database of practicality will be an important factor for development of D language in the future

2017-02-06 Thread Jack Applegame via Digitalmars-d
On Thursday, 2 February 2017 at 13:28:48 UTC, Shachar Shemesh wrote: On 02/02/17 14:50, Adam D. Ruppe wrote: On Thursday, 2 February 2017 at 05:33:57 UTC, FrankLike wrote: For example, I want to do the execution of stored procedure for MSSql、MySQL database. I found in Mysql-d, Mysql-Native,

Re: How about a special null template parameter?

2016-08-19 Thread Jack Applegame via Digitalmars-d
On Friday, 19 August 2016 at 18:25:06 UTC, Engine Machine wrote: It replaces the current method of having to define a non-templated class and a templated class. e.g., class Type { int x; } class Type(T) : Type { static if (T is Dog) int y; } What are you talking about? This code

D Language Foundation

2016-09-30 Thread Jack Applegame via Digitalmars-d
Is there a way to donate to the D Language Foundation?

Challenge on Russian Stack Overflow

2016-11-11 Thread Jack Applegame via Digitalmars-d
I found funny (from my point of view) challenge in Russian Stack Overflow. Any language accepted. You need to make the loop for (int x=0; x<3; ++x) {} endless. Rules: - you can't modify the loop's code itself; - you can't modify the loop's variable inside the body of loop; - you can't wrap

How do we accelerate the development of precise GC, RC and so on?

2016-11-22 Thread Jack Applegame via Digitalmars-d
We look forward to sane GC over the years. How do we accelerate the development of precise GC, RC and so on? Maybe we should organize a fundraiser on Kickstarter or somewhere else? I'm not ready to write precise GC, but I'm willing to donate to those who are ready.

Re: How do we accelerate the development of precise GC, RC and so on?

2016-11-24 Thread Jack Applegame via Digitalmars-d
So, who wants to do a good deed and make some money? We can create an issue and start fundraising on Bountysource. We can also donate to the D Language Foundation, but I personally would like to see the funds were used to develop precise GC and DIP74 (https://wiki.dlang.org/DIP74).

Re: Red Hat's issues in considering the D language

2016-12-22 Thread Jack Applegame via Digitalmars-d
On Thursday, 22 December 2016 at 08:33:55 UTC, Daniel Kozák wrote: ? I am on fedora and I have dmd, so it is not true :P Dejan Lekic via Digitalmars-d napsal St, pro 21, 2016 v 6∶36 : On Wednesday, 21 December 2016 at 16:41:56 UTC, hardreset wrote: Moving the

Re: It is still not possible to use D on debian/ubuntu

2017-01-14 Thread Jack Applegame via Digitalmars-d
On Saturday, 14 January 2017 at 18:41:21 UTC, Russel Winder wrote: On Sat, 2017-01-14 at 17:28 +, Elronnd via Digitalmars-d wrote: On Friday, 13 January 2017 at 11:50:25 UTC, Russel Winder wrote: > LDC which is packaged by both Debian and Fedora is the > only practically usable D compiler

Something wrong with reflection inside struct destructor

2017-03-14 Thread Jack Applegame via Digitalmars-d
I'm trying to write reference counted dynamic array and encountered a trouble with compile time reflection at recursive template instantiation. for dynamic arrays (and AA too) it is normal to use recursive declarations: struct S { S[] arr; } struct S { Array!S arr; } Look at this

Re: Something wrong with reflection inside struct destructor

2017-03-14 Thread Jack Applegame via Digitalmars-d
On Tuesday, 14 March 2017 at 12:44:16 UTC, Jack Applegame wrote: Workaround: Avoid reflection in the destructor. Do reflection in normal function and then call it from destructor. This doesn't work - https://dpaste.dzfl.pl/5a1d93f7a277 Call from destructor changes compiler behavior. This is

Re: Something wrong with reflection inside struct destructor

2017-03-14 Thread Jack Applegame via Digitalmars-d
This is completely unacceptable: DPaste(https://dpaste.dzfl.pl/f54f578c4ec9) import std.stdio; import std.string; import std.experimental.allocator; import std.experimental.allocator.mallocator : Mallocator; struct Bar(E) { E* ptr = null; void allocate(int m) { ptr =

Re: Something wrong with reflection inside struct destructor

2017-03-14 Thread Jack Applegame via Digitalmars-d
On Tuesday, 14 March 2017 at 14:33:49 UTC, John Colvin wrote: bug report? https://issues.dlang.org/show_bug.cgi?id=17257

Bug or feature?

2017-03-14 Thread Jack Applegame via Digitalmars-d
https://forum.dlang.org/post/yjddbxzqzvmlvqrht...@forum.dlang.org

Re: Bug or feature?

2017-03-14 Thread Jack Applegame via Digitalmars-d
Sorry, right link - https://forum.dlang.org/thread/okbzqkjijuwvmvstj...@forum.dlang.org

Re: Move construction from !is(T == typeof(this))

2017-04-25 Thread Jack Applegame via Digitalmars-d
On Monday, 24 April 2017 at 18:48:00 UTC, Stanislav Blinov wrote: Suddenly, we can't copy the pointer, or at least make a shallow copy of it, without violating const, and the latter is UB. Because transitive const/immutable is shit. And that shit had to introduce another shit - Rebindable. D

Re: Move construction from !is(T == typeof(this))

2017-04-25 Thread Jack Applegame via Digitalmars-d
On Tuesday, 25 April 2017 at 08:53:22 UTC, Stanislav Blinov wrote: On Tuesday, 25 April 2017 at 07:58:43 UTC, Jack Applegame wrote: On Monday, 24 April 2017 at 18:48:00 UTC, Stanislav Blinov wrote: Suddenly, we can't copy the pointer, or at least make a shallow copy of it, without violating

LDC, ARM: unnecessary default initialization

2017-08-18 Thread Jack Applegame via Digitalmars-d
I explore the possibility of using D for bare metal ARM programming. For some reason, the LDC default initializes the structure, even if initialization of all its members is specified as void. I believe that this is wrong. test.d module test; import

Re: gdc is in

2017-10-08 Thread Jack Applegame via Digitalmars-d
On Sunday, 8 October 2017 at 08:38:15 UTC, Iain Buclaw wrote: Donating for the upkeep of our infrastructure is also welcome. ;-) How to do this?

Temporary objects as function parameters or when-is-this-shit-going-to-end?

2017-10-13 Thread Jack Applegame via Digitalmars-d
Sorry, I mistakenly placed my post in the wrong section. Consider, please: https://forum.dlang.org/thread/oxucajbsjbsuraqtn...@forum.dlang.org

Re: Temporary objects as function parameters or when-is-this-shit-going-to-end?

2017-10-13 Thread Jack Applegame via Digitalmars-d
On Friday, 13 October 2017 at 10:55:24 UTC, rikki cattermole wrote: On 13/10/2017 11:40 AM, Jack Applegame wrote: Please create an issue for this Done. https://issues.dlang.org/show_bug.cgi?id=17897 To anybody else, the poster is willing to pay a token to have this fixed. [0]

Re: LDC, ARM: unnecessary default initialization

2017-08-19 Thread Jack Applegame via Digitalmars-d
On Friday, 18 August 2017 at 17:28:38 UTC, kinke wrote: On Friday, 18 August 2017 at 12:09:04 UTC, kinke wrote: On Friday, 18 August 2017 at 09:42:25 UTC, Jack Applegame wrote: For some reason, the LDC default initializes the structure, even if initialization of all its members is specified as

Re: How to extract the AA type?

2017-12-13 Thread Jack Applegame via Digitalmars-d
auto foo(T: V[K], V, K)(T t) { CopyConstness!(T, V[K]) aa = t; return aa; } https://run.dlang.io/is/LSMa5C

Confusing TLS

2018-03-13 Thread Jack Applegame via Digitalmars-d
Code: import std.stdio; import core.thread; import core.time; auto arr = new ubyte[1]; // THIS SHOULD NOT COMPILE int main(string[] args) { new Thread({ arr[0]++; }).start(); new Thread({ arr[0]++; }).start(); Thread.sleep(1.seconds); writefln("arr[0]

Re: Deep nesting vs early returns

2018-10-04 Thread Jack Applegame via Digitalmars-d
On Thursday, 4 October 2018 at 06:43:02 UTC, Gopan wrote: Certain people recommend that there be only one return statement (usually at the end) from a function. The said advantage is that, in a maintenance code, if you later want to do something before returning, you can add it just above the

Re: Mono-D 2.0 - XamarinStudio 5.0 support, completion improvements

2014-05-03 Thread Jack Applegame via Digitalmars-d-announce
At first, thank you. There is an issue with Diet templates highlighting. It's very poor. Just compare Mono-D 2.0.1/Xamarian Studio 5.0 - http://a-rei.ru/eNhp Sublime Text 3 - http://a-rei.ru/vuoY

Re: Mono-D 2.0 - XamarinStudio 5.0 support, completion improvements

2014-05-03 Thread Jack Applegame via Digitalmars-d-announce
On Saturday, 3 May 2014 at 11:37:58 UTC, Alexander Bothe wrote: On Saturday, 3 May 2014 at 11:28:25 UTC, Alexander Bothe wrote: But thanks for noticing that regression. No, it actually is working. Your file has to end with '.dt' to have proper highlighting. A screenshot I just took:

Very strange compilation error

2014-10-15 Thread Jack Applegame via Digitalmars-d-learn
I don't understand why this code doesn't compile: http://dpaste.dzfl.pl/dfd8df7f80ad

Why std.variant.Varian.get is mutable

2014-10-21 Thread Jack Applegame via Digitalmars-d-learn
This doesn't compiles http://dpaste.dzfl.pl/bbcc31fbe016

transversal sum

2014-11-06 Thread Jack Applegame via Digitalmars-d-learn
I have rectangular forward range of forward ranges (not arrays): [ [a11, a12, ... a1N], [a21, a22, ... a2N], ... [aM1, aM2, ... aMN] ] I need lazy forward range: [ a11 + a21 + ... aM1, a12 + a22 + ... aM2, ... a1N + a2N + ... aMN ] Range of sum elements of every columns; M, N -

Re: transversal sum

2014-11-06 Thread Jack Applegame via Digitalmars-d-learn
void popFront() { foreach (ref r; rr) r.popFront(); } I think it should be void popFront() { foreach (ref r; rr.save) r.popFront(); } but I think OP wanted a ready-made phobos solution, w/o all the range boilerplate... exactly.

std.array.array and immutable elements

2014-11-07 Thread Jack Applegame via Digitalmars-d-learn
DMD64 D Compiler v2.066.1 Why second call doesn't compile? import std.array; import std.algorithm; class Foo { bool flag; } void main() { immutable(Foo)[] foos; foreach(i; 0..5) foos ~= new Foo; // compiles, typeof(bar1) == immutable(Foo)[] auto bar1 =

Re: Russian translation of the range term?

2014-11-12 Thread Jack Applegame via Digitalmars-d-learn
интервал, область

struct vs built-in type

2014-12-17 Thread Jack Applegame via Digitalmars-d-learn
Code: import std.stdio; struct Bar { int payload; alias payload this; } struct Foo { private { Bar m_bar; int m_baz; } @property { Bar bar() { return m_bar; } void bar(Bar v) { m_bar = v; }

Re: struct vs built-in type

2014-12-17 Thread Jack Applegame via Digitalmars-d-learn
On Wednesday, 17 December 2014 at 08:09:44 UTC, Daniel Kozák via Digitalmars-d-learn wrote: This should work only with ref by spec I totally agree.

Re: The best way to compare floating point values.

2015-02-14 Thread Jack Applegame via Digitalmars-d-learn
On Saturday, 14 February 2015 at 10:23:48 UTC, Gary Willoughby wrote: I wrote a similar function here: https://github.com/nomad-software/dunit/blob/master/source/dunit/toolkit.d#L42 or using an epsilon value: https://github.com/nomad-software/dunit/blob/master/source/dunit/toolkit.d#L134 I

std.conv.to purity

2015-02-14 Thread Jack Applegame via Digitalmars-d-learn
why std.conv.to is not pure? string foo(real v) pure { return v.to!string; } // Error: pure function 'foo' cannot call impure function 'std.conv.to!string.to!(real).to'

The best way to compare floating point values.

2015-02-14 Thread Jack Applegame via Digitalmars-d-learn
I wrote this function for comparing two floating point values: import std.math; import std.traits; bool isEqual(T)(T v1, T v2) if(isFloatingPoint!T) { return T.mant_dig - feqrel(v1, v2) 2; } What do you think about it?

is expression and type tuples

2015-03-03 Thread Jack Applegame via Digitalmars-d-learn
Seems like is expression doesn't support type tuples: pragma(msg, is(short : int)); // true enum Test(ARGS...) = is(ARGS[0..2] : ARGS[2..4]); pragma(msg, is(Test!(int, int, int, int))); // false pragma(msg, Test!(int, short, int, int)); // false Is it by design, or just

Re: is expression and type tuples

2015-03-03 Thread Jack Applegame via Digitalmars-d-learn
On Tuesday, 3 March 2015 at 16:42:22 UTC, bearophile wrote: But it should be not too much hard to implement it your code. Just use two is(), or use recursion (with splitting in two, and not 1 + n-1). Bye, bearophile I already have one: template Is(ARGS...) if(ARGS.length % 2 == 0) {

Re: I want to introduce boost_asio to dlang

2015-03-05 Thread Jack Applegame via Digitalmars-d-learn
On Thursday, 5 March 2015 at 06:05:56 UTC, zhmt wrote: I am a gameserver developer, my programming lang is java now. I want to change java to dlang, and I like boost_asio and it's coroutine, so, I want to create a binding of boost_asio. But I am not familiar with dlang, so I want to find

Re: is expression and type tuples

2015-03-03 Thread Jack Applegame via Digitalmars-d-learn
On Tuesday, 3 March 2015 at 17:49:24 UTC, bearophile wrote: That's 1 + n-1 :-) Could you please explain what does '1 + n-1' mean?

SysTime.toISOExtString with timezone offset

2015-04-20 Thread Jack Applegame via Digitalmars-d-learn
I need current system time ISO string with timezone offset. For example 2015-04-20T11:00:44.735441+03:00 but Clock.currTime.toISOExtString doesn't write offset: 2015-04-20T11:00:44.735441+03:00 I found workaround, but it looks redundant and needs memory allocation: auto t = Clock.currTime;

Bug or feature?

2015-05-10 Thread Jack Applegame via Digitalmars-d-learn
code: class A { void test(int) {} } class B : A { void test() { super.test(1); // compiles test(10); // error } } Error: function B.test () is not callable using argument types (int)

Re: Bug or feature?

2015-05-10 Thread Jack Applegame via Digitalmars-d-learn
Ok, it's a feature. Thanks.

Re: D needs...

2015-05-14 Thread Jack Applegame via Digitalmars-d-announce
What about mutable references to immutable/shared/const classes? class A {} immutable(A)[int] aa; aa[1] = new immutable A;// doesn't compile Rebindable!(immutable(A))[int]; // looks like ugly shamefull workaround.

Re: How to create a mutable array of strings?

2015-05-17 Thread Jack Applegame via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:10:06 UTC, Dennis Ritchie wrote: It's uncomfortable: - char[][] s = [['f', 'o', 'o'], ['b', 'a', 'r']]; s[1][1] = 't'; auto s = [foo.dup, bar.dup]; s[1][1] = 't';

Re: return the other functions of the void main()

2015-04-09 Thread Jack Applegame via Digitalmars-d-learn
I quite often have to write similar designs: - import std.stdio; void main() { auto a = [ 1, 2, 3, 4, 5 ]; foreach (e; a) { if (e == 4) { writeln(Yes); return; } }

Mutable reference for immutable AA

2015-05-29 Thread Jack Applegame via Digitalmars-d-learn
I need mutable storage for immutable associative array. Just create new immutable AA and store it for future passing it between threads/fibers. First attempt: just immutable AA immutable aa = [1:1, 2:1]; aa = [1:1, 2:1]; // fail, can't assign a new AA Second attempt: mutable AA with immutable

Re: Mutable reference for immutable AA

2015-05-29 Thread Jack Applegame via Digitalmars-d-learn
I made trivial pull request - https://github.com/D-Programming-Language/phobos/pull/3341 RebindableAA!(immutable int[string]) aa = [a: 1, b: 2]; // works assert(aa[a] == 1); // cool aa = [a: 3, b: 4]; // nice auto bb = aa; // yes bb = [a: 4, b: 5]; // super aa[a] = 2; //

Bug or feature?

2015-06-28 Thread Jack Applegame via Digitalmars-d-learn
I don't see any reason why it should not compile. import std.array; import std.range; import std.algorithm; class Foo { } void main() { auto result = iota(3).map!(i = new immutable Foo).array(); } /usr/include/dmd/phobos/std/conv.d(4028): Error: cannot implicitly convert expression

Re: Bug or feature?

2015-06-30 Thread Jack Applegame via Digitalmars-d-learn
https://issues.dlang.org/show_bug.cgi?id=14751

goroutines vs vibe.d tasks

2015-06-30 Thread Jack Applegame via Digitalmars-d-learn
Just creating a bunch (10k) of sleeping (for 100 msecs) goroutines/tasks. Compilers go: go version go1.4.2 linux/amd64 vibe.d: DMD64 D Compiler v2.067.1 linux/amd64, vibe.d 0.7.23 Code go: http://pastebin.com/2zBnGBpt vibe.d: http://pastebin.com/JkpwSe47 go version build with go

Re: goroutines vs vibe.d tasks

2015-06-30 Thread Jack Applegame via Digitalmars-d-learn
On Tuesday, 30 June 2015 at 17:37:38 UTC, Atila Neves wrote: Sleep will almost certainly pause and block the fiber. Vibe.d only switches between them when there's IO to be done or something else from the event loop. Sleep blocks the fiber, but not the event loop. Because it isn't

Re: Bug or feature?

2015-08-04 Thread Jack Applegame via Digitalmars-d-learn
fix - https://github.com/D-Programming-Language/phobos/pull/3524

Re: std.algorithm each documentation terse

2015-07-20 Thread Jack Applegame via Digitalmars-d-learn
Also, map is lazy, but each isn't.

dmd 2.068 deducing purity

2015-08-25 Thread Jack Applegame via Digitalmars-d-learn
Using lambdas in 2.068 becomes painful: import std.algorithm; struct Foo { int baz(int v) { static int id; return v + id++; } void bar() { auto arr1 = [1, 2, 3]; auto arr2 = [4, 5, 6];

Re: dmd 2.068 deducing purity

2015-08-25 Thread Jack Applegame via Digitalmars-d-learn
On Tuesday, 25 August 2015 at 14:05:17 UTC, Steven Schveighoffer wrote: Can you post an example? import std.range; import std.algorithm; class Foo { int baz() { return 1;} void bar() { auto s = [1].map!(i = baz()); // compiles auto r = [1].map!(i =

Re: Fastest JSON parser in the world is a D project

2015-10-29 Thread Jack Applegame via Digitalmars-d-announce
On Thursday, 29 October 2015 at 12:11:54 UTC, Suliman wrote: Marco, could you add your lib to review or do any steps that will help to include it's in Phobos? I think not only I interesting in good base JSON lib in base distribution. Marco's json library doesn't meet requirements for

Re: dmd 2.068 deducing purity

2015-08-25 Thread Jack Applegame via Digitalmars-d-learn
On Tuesday, 25 August 2015 at 18:03:21 UTC, Steven Schveighoffer wrote: https://issues.dlang.org/show_bug.cgi?id=14962 -Steve Thanks.

Re: Can't understand how to do server response with vibed

2015-12-02 Thread Jack Applegame via Digitalmars-d-learn
On Saturday, 28 November 2015 at 18:03:13 UTC, Suliman wrote: Could anybody help me to understand how to complete HTTP response with vibed. I am sending POST request from AngularJS: $.post("http://127.0.0.1:8080/my;, total_result); where total_result is JSON string: [{"QID":3,"AID":3},

GC greediness

2016-01-05 Thread Jack Applegame via Digitalmars-d-learn
On a server with 4GB of RAM our D application consumes about 1GB. Today we have increased server memory to 6 Gb and the same application under the same conditions began to consume about 3Gb of memory. Does GC greediness depend on available RAM?

About Immutable struct members and arrays.

2016-01-06 Thread Jack Applegame via Digitalmars-d-learn
import std.algorithm; struct Bar { const int a; int b; } void main() { Bar[1] arr; Bar bar = Bar(1, 2); bar[0].b = 4; move(bar, arr[0]); // ok arr[1] = bar;// fail, why? move(Bar(1, 2), arr[0]); // fail, why source parameter isn't auto ref? }

Re: About Immutable struct members and arrays.

2016-01-07 Thread Jack Applegame via Digitalmars-d-learn
On Thursday, 7 January 2016 at 00:19:12 UTC, anonymous wrote: On 06.01.2016 23:04, Jack Applegame wrote: move(bar, arr[0]); // ok I consider it a bug that this compiles. You're overwriting immutable data, which shouldn't be possible (without casting).

Re: Is it a bug?

2015-11-25 Thread Jack Applegame via Digitalmars-d-learn
On Wednesday, 25 November 2015 at 09:31:15 UTC, John Colvin wrote: import std.range; import std.algorithm; import std.utf; void main() { char[64] arr; copy(chain("test1", "test2").byCodeUnit, arr[0..10].byCodeUnit); } I'll use byCodeUnit. Thanks.

Is it a bug?

2015-11-25 Thread Jack Applegame via Digitalmars-d-learn
This doesn't compile: import std.range; import std.algorithm; void main() { char[64] arr; copy(chain("test1", "test2"), arr[0..10]); } http://dpaste.dzfl.pl/24230ac02e6e

Re: Multidimensional AA question

2015-11-27 Thread Jack Applegame via Digitalmars-d-learn
On Thursday, 26 November 2015 at 17:27:34 UTC, André wrote: My question now is: is there some more elegant solution to achieve this? Something like in C++ when you have std::map's of std::map's and just access the elements and the entry is created implicitly? No. But you can create a wrapper:

Re: Multidimensional AA question

2015-11-27 Thread Jack Applegame via Digitalmars-d-learn
On Friday, 27 November 2015 at 04:21:41 UTC, Nicholas Wilson wrote: AA are weird in that AFAIK you need to "initialise" them before you try to look suff up in them else they crash. i.e. int[string] foo; // auto e = "1" in foo; // crash AA not initialised foo[ "blah"] = 0; foo.remove("blah");

Re: char[] == null

2015-11-18 Thread Jack Applegame via Digitalmars-d-learn
On Thursday, 19 November 2015 at 03:53:48 UTC, Meta wrote: On Wednesday, 18 November 2015 at 23:53:01 UTC, Chris Wright wrote: [...] This is not true. Consider the following code: import std.stdio; void main() { int[] a = [0, 1, 2]; //4002E000 3 writeln(a.ptr, " ",

Re: char[] == null

2015-11-19 Thread Jack Applegame via Digitalmars-d-learn
I prefer import std.array; if(!arr.empty) {}

Re: pure vs immutable

2015-11-19 Thread Jack Applegame via Digitalmars-d-learn
Heh immutable Foo foo2 = new Foo("bar"); // compiles

pure vs immutable

2015-11-19 Thread Jack Applegame via Digitalmars-d-learn
I believe that object constructed with pure constructor should be implicitly convertible to immutable. It is, but only for default constructor. class Foo { string s; this() pure { s = "fpp"; } this(string p) pure { s = p; } } void main() { auto foo1 = new immutable

Re: Manually allocate delegate?

2015-11-21 Thread Jack Applegame via Digitalmars-d-learn
On Sunday, 12 July 2015 at 08:38:01 UTC, Tofu Ninja wrote: Is it even possible? You can use function instead delegate, and bind captured variables as struct: http://dpaste.dzfl.pl/6e23bbcfe17f auto bind(F: R function(ARGS), R, ARGS...)(F fn, ARGS args) @nogc { struct Functor {

Re: Why does array loses it internal capacity on length change?

2016-03-12 Thread Jack Applegame via Digitalmars-d-learn
Why is this happening...? For safety reasons. Your array can be shared between parts of application. ...how to avoid it? https://dlang.org/library/object/assume_safe_append.html

Re: mutable keyword

2016-05-20 Thread Jack Applegame via Digitalmars-d-learn
On Friday, 20 May 2016 at 17:28:55 UTC, Namespace wrote: But you can cheat: You can just cast const away: struct A { int id = 0; this(int id) { this.id = id; } void change() const { (cast() id)++; } }

Re: mutable keyword

2016-05-23 Thread Jack Applegame via Digitalmars-d-learn
On Monday, 23 May 2016 at 11:05:34 UTC, Jonathan M Davis wrote: I don't know why you think that D violates its own rules frequently though. It's not perfect, but it usually does follow its own rules - and when it doesn't, we fix it (though not always as quickly as would be ideal). The most

Re: mutable keyword

2016-05-23 Thread Jack Applegame via Digitalmars-d-learn
On Sunday, 22 May 2016 at 13:08:19 UTC, Jonathan M Davis wrote: Given how const and immutable work in D, having any portion of them be treated as mutable, becomes highly problematic. It could theoretically be done by having to mark such variables with an attribute and mark such types with a

Re: mutable keyword

2016-05-21 Thread Jack Applegame via Digitalmars-d-learn
On Friday, 20 May 2016 at 20:46:18 UTC, Jonathan M Davis wrote: Casting away const and mutating is undefined behavior in D. No D program should ever do it. Really? Mutating immutable is UB too, but look at std.typecons.Rebindable.

Re: mutable keyword

2016-05-22 Thread Jack Applegame via Digitalmars-d-learn
On Saturday, 21 May 2016 at 21:49:23 UTC, Jonathan M Davis wrote: Rebindable is in kind of a weird grey area. It involves a union, not casting, and it's only ever mutating the class reference, not the object itself. Certainly, if it mutated the object, it would be undefined behavior, but it's

Re: Looking for D developers, Saint-Petersburg

2016-05-10 Thread Jack Applegame via Digitalmars-d-announce
On Tuesday, 10 May 2016 at 14:39:27 UTC, drug wrote: I'm curious are there D developers in Saint Petersburg who doesn't mind to make some money? Вопрос, зачем нужно высшее образование? Хорошего знания D/C++ недостаточно? И как часто нужно кататься в офис?

Re: D-Man culture

2016-07-28 Thread Jack Applegame via Digitalmars-d-announce
On Thursday, 28 July 2016 at 01:58:13 UTC, ketmar wrote: On Wednesday, 27 July 2016 at 19:50:13 UTC, Walter Bright wrote: While I appreciate the effort and the offer, it is inappropriate to have a woman with a miniskirt and partially unbuttoned blouse as an official mascot for D. i agree.

Possible bug

2016-07-05 Thread Jack Applegame via Digitalmars-d-learn
ttt.d import std.string; void main() { lastIndexOf("aa","bb"); } rdmd ttt.d compiles successfully without any errors or warnings rdmd -dw ttt.d compiles successfully without any errors or warnings rdmd -de ttt.d /usr/include/dmd/phobos/std/string.d(1239): Error: template

Re: Possible bug

2016-07-05 Thread Jack Applegame via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 13:48:50 UTC, ag0aep6g wrote: Something is also going wrong in dmd. There should be a deprecation message. Exactly.

Re: Does vibe.d support setting cookies?

2017-02-01 Thread Jack Applegame via Digitalmars-d-learn
On Wednesday, 1 February 2017 at 14:09:41 UTC, aberba wrote: I can't find it. Like set_cookie() in php. Yes, it does. http://vibed.org/api/vibe.http.common/HTTPResponse.cookies

Re: Another bug?

2017-01-30 Thread Jack Applegame via Digitalmars-d-learn
bug report: https://issues.dlang.org/show_bug.cgi?id=17128

Another bug?

2017-01-30 Thread Jack Applegame via Digitalmars-d-learn
Code: import std.stdio; struct Foo { int val = 0; ~this() { writefln("destruct %s", val); } } void bar(ARGS...)() { ARGS args; args[0].val = 1; writefln("val = %s", args[0].val); } void main() { bar!Foo(); } Excpected output: val = 1 destruct 1 But

Re: Another bug?

2017-01-30 Thread Jack Applegame via Digitalmars-d-learn
WORKAROUND: import std.stdio; struct Foo { int val = 0; ~this() { writefln("destruct %s", val); } } void bar(ARGS...)() { struct Tuple { ARGS args; alias args this; } Tuple args; args[0].val = 1; writefln("val = %s", args[0].val); }

  1   2   >