Re: What wrong?

2015-05-15 Thread anonymous via Digitalmars-d
On Monday, 4 May 2015 at 08:48:47 UTC, Fyodor Ustinov wrote: Simple code: http://pastebin.com/raw.php?i=7jVeMFXQ This code works compiled by DMD v2.066.1 and LDC2 (0.15.1) based on DMD v2.066.1 and LLVM 3.5.0. $ ./z TUQLUE 42 11 Compiled by DMD v2.067.1 the program crashes: $ ./aa TUQLUE

Re: Any plans to support STL value types?

2015-05-15 Thread anonymous via Digitalmars-d
On Friday, 15 May 2015 at 19:44:29 UTC, Jonathan M Davis wrote: On Friday, 15 May 2015 at 18:42:31 UTC, Kagamin wrote: Many STL types inherit from base classes, yet they are used as value types: std::string, std::vector etc. Are there plans to support C++ types with inheritance as proper value

Re: Dynamic / resizable array type, and a crash problem

2015-05-15 Thread anonymous via Digitalmars-d-learn
On Thursday, 14 May 2015 at 20:50:05 UTC, ivoras wrote: I'm experimenting to get a feel for the language. Do you have a suggestion about this example code: https://goo.gl/F7LCAg to make it more D-like, idiomatic? Quoting from the code: for (int i = 0; i count; i++) { foreach(i; 0 ..

Re: Dynamic / resizable array type, and a crash problem

2015-05-14 Thread anonymous via Digitalmars-d-learn
On Thursday, 14 May 2015 at 12:42:01 UTC, ivoras wrote: https://gist.github.com/ivoras/2d7737c214c3dc937c28 The crash is at line 20: core.exception.AssertError@/usr/include/dmd/phobos/std/container/array.d(334): [...] This is on DMD32 D Compiler v2.067.1 Seems to be fixed in git head.

Re: Cannot Qualify Variadic Functions with Lazy Arguments as nothrow

2015-05-14 Thread anonymous via Digitalmars-d-learn
On Thursday, 14 May 2015 at 09:53:20 UTC, Per Nordlöw wrote: I'm almost satisified with it except that the lazy evaluation at https://github.com/nordlow/justd/blob/master/algorithm_ex.d#L45 cannot be made nothrow. If I qualify the function as nothrow DMD complains as algorithm_ex.d(45,16):

Re: D looses in speed to Common Lisp

2015-05-12 Thread anonymous via Digitalmars-d
On Monday, 11 May 2015 at 23:32:48 UTC, Dzhon Smit wrote: Could you re-run sbcl? The first time it runs it creates fasls, and afterwards it reuses them. Probably you shouldn't include the compile time for dmd either. Sure thing. I think that wasn't the first run already. But to make sure,

Re: D looses in speed to Common Lisp

2015-05-12 Thread anonymous via Digitalmars-d
On Tuesday, 12 May 2015 at 14:58:40 UTC, Vladimir Panteleev wrote: There is no way around this if you want your message to reach NNTP and mailing list users, which are about half of the posters here. The relevant protocols require a valid-looking email address in the From header. As the help

Re: D looses in speed to Common Lisp

2015-05-11 Thread anonymous via Digitalmars-d
On Monday, 11 May 2015 at 21:15:33 UTC, Dzhon Smit wrote: Tests on my machine: [code]$ time ./fib 0 real0m6.458s user0m2.250s sys 0m0.933s $ time sbcl --dynamic-space-size 4GB --script fib.lisp 0 real0m1.884s user0m1.290s sys 0m0.260s[/code] Can't confirm that. Times

Re: A few thoughts on std.allocator

2015-05-10 Thread anonymous via Digitalmars-d
On Sunday, 10 May 2015 at 09:50:00 UTC, Andrei Alexandrescu wrote: (file:///Users/aalexandre/code/d/dlang.org/web/phobos-prerelease/std_experimental_allocator_free_tree.html) bad link

Re: how does 'shared' affect member variables?

2015-05-09 Thread anonymous via Digitalmars-d-learn
On Saturday, 9 May 2015 at 18:41:59 UTC, bitwise wrote: What does 'shared' do to member variables? Makes them `shared`. :P It makes sense to me to put it on a global variable, but what sense does it make putting it on a member of a class? Globals are not the only way to pass data to other

Re: how does 'shared' affect member variables?

2015-05-09 Thread anonymous via Digitalmars-d-learn
On Saturday, 9 May 2015 at 19:59:58 UTC, tcak wrote: Stupidly, shared variables' value cannot be increased/decreased directly. Compiler says it is deprecated, and tells me to use core.atomic.atomicop. You will see this as well. How's that stupid? Sounds like the compiler is doing its job

Re: Multiple template alias parameters

2015-05-08 Thread anonymous via Digitalmars-d-learn
On Friday, 8 May 2015 at 22:29:28 UTC, Biotronic wrote: Sadly, the ... syntax precludes the use of __LINE__ and __FILE__. :( You can put them in the runtime parameters: void traceVars(alias T, U...)(size_t line = __LINE__, string file = __FILE__) { import std.stdio : writeln;

Re: Bitfield-style enum to strings?

2015-05-07 Thread anonymous via Digitalmars-d-learn
On Thursday, 7 May 2015 at 20:55:42 UTC, Nick Sabalausky wrote: // There's gotta be a better way to convert EnumMembers!T // to a range, right? But std.range.only() didn't work, // due to a template instantiation error. T[] members; foreach(m; EnumMembers!(T)) members

Re: Linker command

2015-05-06 Thread anonymous via Digitalmars-d-learn
On Wednesday, 6 May 2015 at 19:52:44 UTC, Paul wrote: On Wednesday, 6 May 2015 at 19:30:33 UTC, anonymous wrote: On Wednesday, 6 May 2015 at 19:26:40 UTC, Paul wrote: but I don't understand the syntax. dmd --help mentions -Llinkerflag but what is '-L-L.' doing?? Passes '-L.' to the linker.

Re: Linker command

2015-05-06 Thread anonymous via Digitalmars-d-learn
On Wednesday, 6 May 2015 at 19:26:40 UTC, Paul wrote: but I don't understand the syntax. dmd --help mentions -Llinkerflag but what is '-L-L.' doing?? Passes '-L.' to the linker.

Re: Phobos master broken ?

2015-05-05 Thread anonymous via Digitalmars-d
On Monday, 4 May 2015 at 14:32:16 UTC, Martin Krejcirik wrote: I can't seem to build phobos master on linux, unless I revert pull #3014 unittests DMD v2.067-devel-b9dee9e DEBUG std/math.d(2702): Error: number '0x1p-1024' is not representable std/math.d(2705): Error: number '0x1p-1024' is not

Re: What wrong?

2015-05-04 Thread anonymous via Digitalmars-d
On Monday, 4 May 2015 at 08:48:47 UTC, Fyodor Ustinov wrote: Simple code: http://pastebin.com/raw.php?i=7jVeMFXQ This code works compiled by DMD v2.066.1 and LDC2 (0.15.1) based on DMD v2.066.1 and LLVM 3.5.0. $ ./z TUQLUE 42 11 Compiled by DMD v2.067.1 the program crashes: $ ./aa TUQLUE

Re: CTFE template predicates

2015-05-04 Thread anonymous via Digitalmars-d-learn
On Monday, 4 May 2015 at 11:22:16 UTC, Robert M. Münch wrote: Hi, ok, just to better understand this (I have a C++ background (even quite old)): When I want to use some functions I need to specify the type? It's not possible to use T.length() which would compile if T is a string? I thought

Re: CTFE template predicates

2015-05-04 Thread anonymous via Digitalmars-d-learn
On Monday, 4 May 2015 at 11:41:23 UTC, Robert M. Münch wrote: Hi, I have one more questions: Is it possible to write something like this? alias rules = StaticFilter!(startsNotWith(?, 'p'), org_rules); The ? should be used for every memember of org_rules. No, we don't have template literals.

Re: opEquals optimized away?

2015-05-04 Thread anonymous via Digitalmars-d-learn
On Tuesday, 5 May 2015 at 04:09:03 UTC, Manfred Nowak wrote: class C{ override bool opEquals( Object o){ return true; } } unittest{ auto c= new C; assert( c == c); } `rdmd --main -unittest -cov' shows, that opEquals is not executed. Why? -manfred because `c is c`

Re: CTFE template predicates

2015-05-03 Thread anonymous via Digitalmars-d-learn
On Sunday, 3 May 2015 at 21:46:11 UTC, Robert M. Münch wrote: Hi, I have now played a around couple of hours (reading everything I could find) to get something to work, but I think I'm missing some basic concepts/understanding. Maybe someone can enlighten me how these things work. I thought

Re: How to I translate this C++ structure/array

2015-05-03 Thread anonymous via Digitalmars-d-learn
On Sunday, 3 May 2015 at 02:31:51 UTC, WhatMeWorry wrote: On Saturday, 2 May 2015 at 22:36:29 UTC, anonymous wrote: [...] [1] `Vertex triangle[6]` works, but please don't do that. Thanks. I assume you would prefer I use triangle[] but with OpenGL calls the dynamic arrays don't work. But

Re: How to I translate this C++ structure/array

2015-05-02 Thread anonymous via Digitalmars-d-learn
On Saturday, 2 May 2015 at 22:01:10 UTC, WhatMeWorry wrote: struct Vertex { vec3 position; vec3 color; } Vertex triangle[6] = [ vec3(0.0, 1.0, 0.0), vec3(1.0, 0.0, 0.0), // red // code removed for brevity. ]; I keep getting

Re: D needs emplacement new

2015-05-01 Thread anonymous via Digitalmars-d
On Monday, 27 April 2015 at 13:12:51 UTC, anonymous wrote: void main() { import std.stdio; import core.memory: GC; auto pointerInDisguise = new size_t; *pointerInDisguise = cast(size_t) cast(void*) new Object; /* Not sure why stomping is necessary, but without this,

Re: Quick Start with D: few examples and set of links.

2015-05-01 Thread Anonymous via Digitalmars-d-announce
Yes, that works. I also tried what John Colvin suggested (.byLine(KeepTerminator.no, std.ascii.newline) and that works too. Is it true that both of those are better than adding chomp because it would be one less time through the pipeline? Learned several new things today! Thanks again! On

Re: Calling functions using mixins

2015-05-01 Thread anonymous via Digitalmars-d-learn
On Friday, 1 May 2015 at 21:04:10 UTC, Dennis Ritchie wrote: hi, Is it possible to call functions using mixins in this way? - import std.stdio; int fooTestMixin() { return 5; } void main() { enum t { fooTestMixin }; immutable string[] strArr = [ fooTestMixin ];

Re: Calling functions using mixins

2015-05-01 Thread anonymous via Digitalmars-d-learn
On Friday, 1 May 2015 at 21:41:10 UTC, Dennis Ritchie wrote: My final goal is to do something like this: - import std.stdio, std.string; int foo() { return 5; } int bar() { return 10; } void main() { immutable string[] s = [ foo, bar ];

Re: How to reuse functions

2015-05-01 Thread anonymous via Digitalmars-d-learn
On Friday, 1 May 2015 at 03:34:53 UTC, Luigi wrote: Hi everybody. I am tring to use a function where its parameter is another function, and at the same time are both already made - they cannot be modified - and the second one has to be conditioned before to be passed as argument. Let's say

Re: Factory pattern in D

2015-05-01 Thread anonymous via Digitalmars-d-learn
On Friday, 1 May 2015 at 11:01:29 UTC, Chris wrote: This aside, how would I get something to load dynamically? It's either mismatched function return type or (with type check) variable X cannot be read at compile time: void main(string[] args) { auto type = args[1]; auto myType =

Re: Interrogative: What's a good blog title?

2015-04-28 Thread anonymous via Digitalmars-d
On Monday, 27 April 2015 at 22:54:07 UTC, Andrei Alexandrescu wrote: Please let me know of any thoughts you might have! Benevolent Destroyer

Re: D needs emplacement new

2015-04-27 Thread anonymous via Digitalmars-d
On Monday, 27 April 2015 at 11:47:46 UTC, Namespace wrote: I create 1000 Foo's 1000 times. After the first iteration there are 1000 unused Foo objects and the GC wants to reallocate another 1000 Foo's. Now, what happen? The GC sees that the previous 1000 objects are unused, remove them and

Re: Delegate type deduction compile error

2015-04-25 Thread anonymous via Digitalmars-d-learn
On Saturday, 25 April 2015 at 10:23:25 UTC, ref2401 wrote: struct MyStruct {} void main(string[] args) { string str = blah-blah; auto d1 = (MyStruct) { writeln(delegate-str: , str); }; writeln(typeid(typeof(d1))); } dmd: 2067 os: Win8.1 build script: dmd main.d

Re: o!(const(T)) parameter.

2015-04-25 Thread anonymous via Digitalmars-d-learn
On Saturday, 25 April 2015 at 14:52:45 UTC, sclytrack wrote: I want a function with parameter o!(const(Form)) to accept both o!(Form) and o!(immutable(Form)) Is there a way to do it? import std.stdio; import std.traits; class Form { int number = 10; } struct o(T) { T

Re: GC.malloc is pure - wat

2015-04-24 Thread anonymous via Digitalmars-d
On Friday, 24 April 2015 at 18:03:50 UTC, David Nadlinger wrote: In case there is further confusion about purity in D, let me do a shameless plug for an article I wrote a couple of years back: http://klickverbot.at/blog/2012/05/purity-in-d/ — David I'm pretty sure that I've read that. But

Re: GC.malloc is pure - wat

2015-04-24 Thread anonymous via Digitalmars-d
On Friday, 24 April 2015 at 17:07:20 UTC, deadalnix wrote: On Friday, 24 April 2015 at 15:43:17 UTC, anonymous wrote: [...] Could core.stdc.stdlib.malloc and friends also be marked pure then? No. Allocating on the GC is stateless as the GC will handle the state by itself, from the program

Re: GC.malloc is pure - wat

2015-04-24 Thread anonymous via Digitalmars-d
On Friday, 24 April 2015 at 15:21:43 UTC, Steven Schveighoffer wrote: This is OK as long as f is *strong* pure. D pure is not the same as the traditional definition. And GC.malloc is not strong pure, as it returns mutable data. Ah, this is the piece I was missing. I was aware of weak/strong

GC.malloc is pure - wat

2015-04-24 Thread anonymous via Digitalmars-d
GC.malloc is marked pure. But it isn't, is it? This should hold for a pure function: assert(f(x) == f(x)); This fails with GC.malloc, of course. Or consider this: auto v = f(x); auto w = f(x); When f is pure, a compiler should be free to reuse the value of v for w. That's no good

Re: GC.malloc is pure - wat

2015-04-24 Thread anonymous via Digitalmars-d
On Friday, 24 April 2015 at 15:29:59 UTC, Marc Schütz wrote: auto a = sin(x) * sin(x);// sin() is called only once Could you give a complete example of when this is done? Two calls here (ldc2 -c -O): real grepme(real x) pure { import std.math; auto a = sin(x) * sin(x); return

Re: GC.malloc is pure - wat

2015-04-24 Thread anonymous via Digitalmars-d
On Friday, 24 April 2015 at 17:57:12 UTC, deadalnix wrote: On Friday, 24 April 2015 at 17:45:57 UTC, anonymous wrote: [...] I can't see how GC.malloc followed by GC.free is more pure than stdlib malloc followed by stdlib free. GC.free should probably not be pure, Ok, fair enough. Right

Re: how does isInputRange(T) actually work?

2015-04-21 Thread anonymous via Digitalmars-d-learn
On Tuesday, 21 April 2015 at 19:17:56 UTC, kevin wrote: On Tuesday, 21 April 2015 at 19:13:34 UTC, Meta wrote: On Tuesday, 21 April 2015 at 19:11:43 UTC, John Colvin wrote: On Tuesday, 21 April 2015 at 19:06:39 UTC, kevin wrote: enum bool isInputRange = is(typeof( (inout int = 0) { R r

Re: Templates: Array slices not recognized

2015-04-20 Thread anonymous via Digitalmars-d-learn
On Monday, 20 April 2015 at 10:14:27 UTC, Chris wrote: string a = bla; string b = blub; auto res = doSomething(a, b); If I didn't use auto ref or ref, string would get copied, wouldn't it? auto ref doSomething(R needle, R haystack); To avoid this, I would have to write a[0..$], b[0..$],

Re: Weird link error

2015-04-20 Thread anonymous via Digitalmars-d-learn
On Monday, 20 April 2015 at 17:02:18 UTC, CodeSun wrote: I have test a snippet of code, and I encountered with a weird link error. The following is the demo: import std.stdio; interface Ti { T get(T)(int num); T get(T)(string str); } class Test : Ti { T get(T)(int num)

Re: Input ranges

2015-04-19 Thread anonymous via Digitalmars-d-learn
On Saturday, 18 April 2015 at 22:01:56 UTC, Ulrich Küttler wrote: Input ranges from std.stdio are used for reading files. So assuming we create a file auto f = File(test.txt, w); f.writeln(iota(5).map!(a = repeat(to!string(a), 4)).joiner.joiner(\n)); f.close(); We should be able

Re: Input ranges

2015-04-19 Thread anonymous via Digitalmars-d-learn
On Sunday, 19 April 2015 at 21:42:23 UTC, Ulrich Küttler wrote: groupBy is a nice example as it laboriously adds reference semantics to forward ranges but assumes input ranges to posses reference semantics by themselves. All ranges are input ranges, though. Input ranges are the least

Could someone review phobos PR #3123, please?

2015-04-17 Thread anonymous via Digitalmars-d
https://github.com/D-Programming-Language/phobos/pull/3123 It's been sitting there for two weeks.

Re: Traits question and compiler crash

2015-04-14 Thread anonymous via Digitalmars-d-learn
On Tuesday, 14 April 2015 at 09:24:04 UTC, Filippo Fantini wrote: Hello everyone! I'm new to D. While playing with around with traits, I ended up writing this short example: module test; class Foo { private int _value = 21; void foo() { import std.traits; alias

Re: CTFE UFCs?

2015-04-14 Thread anonymous via Digitalmars-d-learn
On Tuesday, 14 April 2015 at 15:20:37 UTC, bitwise wrote: When I uncomment the nicer syntax, I get the errors below: [1] Error: variable refl cannot be read at compile time [2] Error: CTFE failed because of previous errors in base class Base { double d = 0.4; } class Test : Base {

Re: Wiki page: Coming From C++

2015-04-12 Thread anonymous via Digitalmars-d
On Sunday, 12 April 2015 at 03:51:50 UTC, Jakob Ovrum wrote: I can't seem to get the compiler to error on dangling else. I tried the examples in the original PR[1], but they seem to compile without error with DMD 2.067. Is anyone able to make the compiler error on dangling else? [1]

Re: UFCS overrides alias this

2015-04-12 Thread anonymous via Digitalmars-d
On Sunday, 12 April 2015 at 20:19:02 UTC, Freddy wrote: test.d struct A{ string b; alias b this; } struct MyRange{ } char front(MyRange); void popFront(ref MyRange); bool empty(MyRange); void test(A a){ a.empty; } $ dmd -o- test test.d(14): Error:

Re: UFCS overrides alias this

2015-04-12 Thread anonymous via Digitalmars-d
On Sunday, 12 April 2015 at 20:48:57 UTC, Freddy wrote: test.d static import std.range; alias empty=std.range.empty; struct A{ string b; alias b this; } struct MyRange{ } char front(MyRange); void popFront(ref MyRange); bool empty(MyRange); void test(A a){

Re: Formatted output ranges

2015-04-11 Thread anonymous via Digitalmars-d-learn
On Saturday, 11 April 2015 at 20:10:49 UTC, Dennis Ritchie wrote: writefln(%(;; %(%s, %),\n%)., [ a[0 .. 15], a[15 .. 30], a[30 .. 45], a[45 .. 60], a[60 .. 75], a[75 .. 90],

Re: function shadowed

2015-04-08 Thread anonymous via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 12:05:00 UTC, ddos wrote: vg.d: module vg; extern (C) void vgSetParameterfv(VGHandle object, VGint paramType, VGint count, VGfloat *values); openvg.d module openvg; public import vg; void vgSetParameterfv(VGHandle object, VGint paramType, const(VGfloat[])

Re: function shadowed

2015-04-08 Thread anonymous via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 22:53:39 UTC, ddos wrote: why not just make it callable without the alias? It's to prevent hijacking: http://dlang.org/hijack.html

Re: Benchmark of D against other languages

2015-04-02 Thread anonymous via Digitalmars-d
On Thursday, 2 April 2015 at 09:09:04 UTC, Martin Nowak wrote: I'm not asking for a linear algebra library in phobos, although we need one in dub and should consider having one in Phobos at some point too. But it would be nice if std.numeric came with a multiply(T)(T[][] a, T[][] b, T[][]

Re: Benchmark of D against other languages

2015-04-02 Thread anonymous via Digitalmars-d
On Wednesday, 1 April 2015 at 22:49:55 UTC, Martin Nowak wrote: ³: Places 2, 3, and 4 thanks to std.numeric.dotProduct. An optimized dense matrix multiplication would get us #1. According to https://github.com/JuliaLang/julia#Required-Build-Tools-External-Libraries building Julia requires

Re: Accessing a field of a containing class from within a nested class

2015-04-01 Thread anonymous via Digitalmars-d-learn
On Wednesday, 1 April 2015 at 18:26:49 UTC, Charles Hixson wrote: Perhaps BTree needs to be a class? yes

Re: is it std.datetime bug?

2015-03-31 Thread anonymous via Digitalmars-d-learn
On Tuesday, 31 March 2015 at 11:51:26 UTC, drug wrote: import std.datetime; import std.stdio; void main() { long.max.SysTime.toISOExtString.writeln; } dmd 2.065 (dpaste.dzfl.pl): +29228-09-14T02:48:05.4775807 dmd v2.067-devel-c6b489b (using Digger): -29227-04-20T00:11:54.5224191

Re: string concatenation with %s

2015-03-30 Thread anonymous via Digitalmars-d-learn
On Monday, 30 March 2015 at 17:18:01 UTC, Suliman wrote: same problem. I am preparing string to next SQL request: string sss = format(SELECT * FROM test.imgs WHERE src LIKE CONCAT('%', REPLACE(CAST(CURDATE()as char), -, ), '%') OR CONCAT('%', CAST(CURDATE()as char), '%')); Here's your code

Re: rvalue based copy

2015-03-30 Thread anonymous via Digitalmars-d-learn
On Monday, 30 March 2015 at 17:21:53 UTC, Steven Schveighoffer wrote: One solution is to overload void opAssign(ref const S s) {...} void opAssign(const S s) {...} lvalues will go into the ref version, rvalues into the non-ref. There won't be any copying of data, so you still save a postblit

Re: string concatenation with %s

2015-03-30 Thread anonymous via Digitalmars-d-learn
On Monday, 30 March 2015 at 17:34:20 UTC, Suliman wrote: string sss = format(foo-, bar); It should be obvious now that you forgot to escape those double quotes. Thanks! Is there any way to stay string as is. without need of it's escaping and so on? It's seems I have seen something like it

Re: Mapping with partial

2015-03-30 Thread anonymous via Digitalmars-d-learn
On Monday, 30 March 2015 at 19:11:10 UTC, matovitch wrote: That settle the point for array as for [] ? I though that was clear. [] doesn't copy. I guess the documentation should have something to say about it too. ;) hopefully

Re: Mapping with partial

2015-03-30 Thread anonymous via Digitalmars-d-learn
On Monday, 30 March 2015 at 19:15:25 UTC, matovitch wrote: Language ref - Array - Slice An array slice does not copy the data, it is only another reference to it. So the total slice of a static array is a range using the underlying memory of the static array isnt it ? yes

Re: Mapping with partial

2015-03-30 Thread anonymous via Digitalmars-d-learn
On Monday, 30 March 2015 at 19:03:05 UTC, matovitch wrote: Well I have a bit of a similar problem with foreach. If I use classic T[] range, I can do : foreach(int i, auto t, myRange)... But if I use an Array!T (from std.container) I get : cannot infer argument types, expected 1 argument, not

Re: Mapping with partial

2015-03-30 Thread anonymous via Digitalmars-d-learn
On Monday, 30 March 2015 at 18:37:53 UTC, matovitch wrote: On Monday, 30 March 2015 at 18:34:19 UTC, Adam D. Ruppe wrote: [...] Aye, that would work too, but the slice I think is more efficient as I'm pretty sure... not completely sure, but I think .array makes a copy of static arrays,

Re: Associative Array of Const Objects?

2015-03-29 Thread anonymous via Digitalmars-d-learn
On Sunday, 29 March 2015 at 19:13:32 UTC, bitwise wrote: Interesting, but I still don't understand why D doesn't have something like this: const Test test;// or const(Test) test; test = new Test() // fine, underlaying data is const, the reference is not Test const test = new Test();

Re: Associative Array of Const Objects?

2015-03-29 Thread anonymous via Digitalmars-d-learn
On Sunday, 29 March 2015 at 18:43:32 UTC, bitwise wrote: I'm a little confused at this point why this doesn't work either: const(Test) test = new Test(); // fine test = new Test(); // error In C++, There is a clear distinction: const Test *test1 = nullptr; // const

Re: Associative Array of Const Objects?

2015-03-29 Thread anonymous via Digitalmars-d-learn
On Sunday, 29 March 2015 at 20:29:50 UTC, bitwise wrote: 3) It's not how C++ rolls. `const Test test;` and `Test const test;` are equivalent in C++. You need that '*' in C++, too, to make a distinction between reference and data. I'm a little confused. I was comparing a C++ pointer-to-class

Re: Human unreadable documentation - the ugly seam between simple D and complex D

2015-03-28 Thread anonymous via Digitalmars-d
On Friday, 27 March 2015 at 18:38:32 UTC, rumbu wrote: schwartzSort it's a nice name only if you are German. Hardly. The name's just as meaningless on its own. It may be easier for us Germans to remember the spelling, but even we have to memorize that tz, as schwarz (black) is more common a

Re: readln() doesn't stop to read the input.

2015-03-28 Thread anonymous via Digitalmars-d
On Saturday, 28 March 2015 at 03:07:31 UTC, jonaspm wrote: module main; import std.stdio; import std.string; int main(string[] args) { int resp; char[] p, q; writefln(MENU DE OPCIONES); writefln(1) Modus Ponens); writefln(2) Modus Tollens); writefln(3) Silogismo

Re: need help with CTFE

2015-03-26 Thread anonymous via Digitalmars-d-learn
On Thursday, 26 March 2015 at 16:19:17 UTC, Dmitri Makarov wrote: When I compile version DOES_NOT_WORK, I get the following error: c/tool.d(13): Error: variable name cannot be read at compile time c/tool.d(13):while looking for match for hasMember!(Tool, name) However, the other

Re: D's type classes pattern ?

2015-03-24 Thread anonymous via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 16:56:13 UTC, matovitch wrote: Thanks, just to be clear : void Bar(T : Foo)(T t){ } is the same as void Bar(T)(T t) if (is(T == Foo)){ } and it is checked only at compile time ? (for the runtime I know that what interface were meant for ;)). Ali already

Re: Where is my memory?

2015-03-22 Thread anonymous via Digitalmars-d
On Sunday, 22 March 2015 at 09:42:41 UTC, Ozan Süel wrote: Hi! I'm working on a Big Data project, where a huge amount of RAM is needed. Using D I've run into a - let's called it - memory leak. I tested this with following code: foreach(i; 0..1000) { int[] ints;

[dlang.org] what to do with remaining orphaned pages

2015-03-22 Thread anonymous via Digitalmars-d
We recently recovered a bunch of pages that were removed from the menu accidentally [1]. Two pages are still orphaned and I'm not sure what to do about them: http://dlang.org/overview.html This was not part of some $(SUBNAV_*), so removal may have been deliberate. But there's no mention of

Re: The difference in string and char[], readf() and scanf()

2015-03-21 Thread anonymous via Digitalmars-d-learn
On Saturday, 21 March 2015 at 08:37:59 UTC, Dennis Ritchie wrote: Tell me, please, why this code works correctly always: [...] And this code works correctly is not always: import std.stdio; readf(%s\n, n); char[200010] s, t; scanf(%s%s, s.ptr, t.ptr); Please go into more detail about how

Re: The difference in string and char[], readf() and scanf()

2015-03-21 Thread anonymous via Digitalmars-d-learn
On Saturday, 21 March 2015 at 15:05:56 UTC, Ivan Kazmenko wrote: Generate a 10-character string: - import std.range, std.stdio; void main () {'a'.repeat (10).writeln;} - Try to copy it with D scanf and printf: - import std.stdio; void main () { char [10] a;

Re: The difference in string and char[], readf() and scanf()

2015-03-21 Thread anonymous via Digitalmars-d-learn
On Saturday, 21 March 2015 at 23:00:46 UTC, Ivan Kazmenko wrote: To me, it looks like a bug somewhere, though I don't get where exactly. Is it in bits of DigitalMars C/C++ compiler code glued into druntime? As far as I understand, the bug is in snn.lib's scanf. snn.lib is Digital Mars's

Re: std.typecons.Proxy + inheritance breaks cast'ing to inherited type

2015-03-17 Thread anonymous via Digitalmars-d-learn
On Tuesday, 17 March 2015 at 07:56:19 UTC, Ali Çehreli wrote: Why can't you do this instead? t opCast(t)() if (is(typeof(cast(T)this))) { return cast(T)this; } That has the same problem: 'cast(T)this' happens to be an explicit cast, which is disabled by the opCast overload for int.

Re: How to test for type without refs?

2015-03-17 Thread anonymous via Digitalmars-d-learn
On Tuesday, 17 March 2015 at 14:06:19 UTC, Charles Hixson wrote: I thought that in: T* user(T)() {static assert (T.sizeof bfHdr.user_.length); static assert (__traits(isPOD, T) ); returncast(T*) bfHdr.user_.ptr; } the line: static assert (__traits(isPOD,

Re: ref for (const) variables

2015-03-16 Thread anonymous via Digitalmars-d-learn
On Monday, 16 March 2015 at 18:47:00 UTC, Namespace wrote: const(Matrix)* m = t.getCurrentModelViewMatrix(); // currently } But IMO it would be a lot nicer if I could store the reference like this: ref const(Matrix) m = t.getCurrentModelViewMatrix(); // nicer [Of course

Re: dfmt options

2015-03-15 Thread anonymous via Digitalmars-d
On Saturday, 14 March 2015 at 23:15:35 UTC, Brian Schott wrote: * Hard limit for line length * Soft limit for line length offset for line wrap, e.g: - right guide = 80; - right tolerance = 10; if line length = 84 then no new line if line length = 91 then new line from the leftmost token

Re: Using std.format required std.string?

2015-03-15 Thread anonymous via Digitalmars-d-learn
On Sunday, 15 March 2015 at 18:03:55 UTC, Robert M. Münch wrote: On 2015-03-15 17:36:24 +, Robert M. Münch said: Is there a way to use version(...) to have code sections depending on compiler version? Something like: version(dmd = 2.067) or version(dmd 2.067)? Answerting myself:

Re: The documentation for std.format needs work

2015-03-15 Thread anonymous via Digitalmars-d
On Sunday, 15 March 2015 at 18:02:30 UTC, Gary Willoughby wrote: The documentation seems to be screwed here: http://dlang.org/phobos/std_format.html Already fixed, just waiting for the release: http://dlang.org/phobos-prerelease/std_format.html

Re: What is: Orphan format arguments: args[0..1]

2015-03-15 Thread anonymous via Digitalmars-d-learn
On Sunday, 15 March 2015 at 18:46:52 UTC, Charles Hixson wrote: What is: Orphan format arguments: args[0..1] It appears to come from within unittest at the line: strings={0}.format(cast(int)d2[i]); It means you gave `format` more arguments than placeholders. `format` uses C style

Re: get from tuple by type

2015-03-15 Thread anonymous via Digitalmars-d-learn
On Sunday, 15 March 2015 at 23:13:58 UTC, Charles Cooper wrote: And yes, I could use names. But then you are subject to name clashes and using strings instead of types as member identifiers is more prone to error anyways. Ever gotten this wrong before -- void CRITICAL_TO_GET_THIS_RIGHT(uint

Re: get from tuple by type

2015-03-15 Thread anonymous via Digitalmars-d-learn
On Sunday, 15 March 2015 at 21:59:18 UTC, Charles Cooper wrote: C++14 has: templateclass T, class... Types constexpr T get(tupleTypes... t); Which allows you to get a member of the tuple struct by type. Is there an idiomatic / library way to do this in D? Preferably by indexing. I don't

Re: Garbage collector returning pointers

2015-03-14 Thread anonymous via Digitalmars-d-learn
On Saturday, 14 March 2015 at 18:26:34 UTC, Robert M. Münch wrote: Hi, I have a question about how the GC handles this case: export extern(C) char* foo(){ char[] x = This is a dynamic D string..dup; return(cast(char*)x); } Returning `x.ptr` would look a little nicer. Since x is pointer

Re: Parallelization of a large array

2015-03-10 Thread anonymous via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 20:41:14 UTC, Dennis Ritchie wrote: Hi. How to parallelize a large array to check for the presence of an element matching the value with the data? std.stdio; std.algorithm; std.parallelism; You forgot a couple imports here. void main() { int[] a =

Re: I wondered what characters are allowed for delimiters in a delimited string

2015-03-06 Thread anonymous via Digitalmars-d
On Friday, 6 March 2015 at 01:44:30 UTC, Philip Miess wrote: The spec seemed a little loose, so I tried the first 256 to see. It is everything minus letters, null and control-z, opening brackets braces, parenthesis whitespace Opening brackets, braces, and parenthesis are allowed; the

Re: Int to float?

2015-03-05 Thread anonymous via Digitalmars-d-learn
On Thursday, 5 March 2015 at 20:03:09 UTC, Benjamin Thaut wrote: int someValue = 5; float sameBinary = *(cast(float*)cast(void*)someValue); The cast(void*) isn't necessary.

Re: Object as function argument

2015-03-05 Thread anonymous via Digitalmars-d-learn
On Thursday, 5 March 2015 at 19:51:09 UTC, Max Klyga wrote: If you really need the actual pointer to object data you can use `*cast(void**)myObject`. Compiler cannot cast object reference to `void*` but we can trick it ;) It can, actually. A class can define its own cast(void*) though, so

Re: Int to float?

2015-03-05 Thread anonymous via Digitalmars-d-learn
On Thursday, 5 March 2015 at 20:21:18 UTC, badlink wrote: On Thursday, 5 March 2015 at 20:16:55 UTC, anonymous wrote: On Thursday, 5 March 2015 at 20:03:09 UTC, Benjamin Thaut wrote: int someValue = 5; float sameBinary = *(cast(float*)cast(void*)someValue); The cast(void*) isn't necessary.

Re: Parallel Merge Sort

2015-03-03 Thread anonymous via Digitalmars-d
On Wednesday, 4 March 2015 at 01:17:00 UTC, H. S. Teoh wrote: The 'in' modifier is the same as 'const' when applied to function parameters, but writing 'in' documents that the parameters are input parameters that won't be modified by the function. You forgot to mention scope. in is short for

Re: strage heisenbug (has scoped destruction, cannot build closure)

2015-03-03 Thread anonymous via Digitalmars-d-learn
On Tuesday, 3 March 2015 at 07:26:13 UTC, ketmar wrote: hi. the following (manually dustmited ;-)) code gives the error from subj on git HEAD: === ztest.d === module ztest; auto streamAsRange(STP) (STP st) { static struct StreamRange(ST) { private: ST strm; public:

Re: Strange alias behaviour in template arguments

2015-03-03 Thread anonymous via Digitalmars-d-learn
On Tuesday, 3 March 2015 at 13:42:09 UTC, Stefan Frijters wrote: So this is a strange thing I ran into while trying to streamline some templates in my code, where fixed-length arrays are passed as runtime arguments. I started out by trying variant fun2(), which disappointingly didn't work.

Re: On opCmp

2015-02-27 Thread anonymous via Digitalmars-d-learn
On Friday, 27 February 2015 at 11:04:51 UTC, Nordlöw wrote: Is there a more compact way to describe the opCmp function in the following struct struct Hit { size_t count; // number of walkers that found this node NWeight rank; // rank (either minimum distance or maximum strength)

Re: DIP74: Reference Counted Class Objects

2015-02-26 Thread anonymous via Digitalmars-d
On Friday, 27 February 2015 at 00:10:00 UTC, deadalnix wrote: On Thursday, 26 February 2015 at 21:50:56 UTC, Andrei Alexandrescu wrote: http://wiki.dlang.org/DIP74 got to reviewable form. Please destroy and discuss. Thanks, Andrei The compiler detects automatically and treats specially all

Re: @trusted and return ref

2015-02-26 Thread anonymous via Digitalmars-d-learn
On Thursday, 26 February 2015 at 10:15:07 UTC, Ola Fosheim Grøstad wrote: On Wednesday, 25 February 2015 at 22:59:01 UTC, anonymous wrote: rule-breaking that's going on there. A public trusted_malloc would invite the un-initiated to shoot their feet. That's entirely social... Sure. A

Re: Installing DMD From Zip

2015-02-26 Thread anonymous via Digitalmars-d-learn
On Thursday, 26 February 2015 at 10:55:40 UTC, Jonathan M Davis wrote: I think that it was the same page, though I could be remembering wrong. Several articles are missing as well (e.g. the one on std.datetime and the one on arrays), so I don't know how careful they really were in updating the

Re: @trusted and return ref

2015-02-26 Thread anonymous via Digitalmars-d-learn
On Thursday, 26 February 2015 at 20:56:52 UTC, Ola Fosheim Grøstad wrote: But it should matter, because when you mark a unit @trusted you basically are signing off a certificate that says it acts like @safe in @safe code. How can you verify anything if you allow injections? If you allow

Re: @trusted and return ref

2015-02-25 Thread anonymous via Digitalmars-d-learn
On Wednesday, 25 February 2015 at 07:07:00 UTC, Ola Fosheim Grøstad wrote: On Wednesday, 25 February 2015 at 00:12:41 UTC, anonymous wrote: [...] That sounds more attractive than the provided example, but the right thing to do is to establish proper encapsulation. That means you need a

<    1   2   3   4   5   6   7   8   9   >