Re: How to initialise array of ubytes?

2014-11-29 Thread bearophile via Digitalmars-d-learn
Daniel Kozak: http://stackoverflow.com/questions/24600796/d-set-default-value-for-a-struct-member-which-is-a-multidimensional-static-arr/24754361#24754361 Do you also know why the simplest syntax doesn't work? Can't it be implemented and added to the D language? Bye, bearophile

Re: D is for Data Science

2014-11-28 Thread bearophile via Digitalmars-d-announce
Tomer Rosenschtein: Awesome article. Paper of the week is a modest word for this. The D code is not good. Bye, bearophile

Re: D is for Data Science

2014-11-28 Thread bearophile via Digitalmars-d-announce
, and I think this is good. Bye, bearophile

Re: Phobos - breaking existing code

2014-11-28 Thread bearophile via Digitalmars-d
Walter Bright: We need to do a lot better. I agree. D has to come back to the living. It looks like D is hibernating. Bye, bearophile

Re: Phobos - breaking existing code

2014-11-28 Thread bearophile via Digitalmars-d
years old D code. Bye, bearophile

Re: Phobos - breaking existing code

2014-11-28 Thread bearophile via Digitalmars-d
development trying to solve it will cause more problems (and more wasted efforts) than it can solve. Bye, bearophile

Re: Phobos - breaking existing code

2014-11-28 Thread bearophile via Digitalmars-d
Walter Bright: Just for fun, I've decided to try and [...] There's a pull in need of some love, I'd like to see this in D: https://github.com/D-Programming-Language/dmd/pull/3615 Bye, bearophile

Re: Phobos - breaking existing code

2014-11-28 Thread bearophile via Digitalmars-d
to the old names can be kept for a long time without causing problems This is usually true, but not always (see above). 3. when removed entirely, the documentation for them should be kept along with instructions on corrective action I agree. Bye, bearophile

Re: Passing reference data to class and incapsulation

2014-11-28 Thread bearophile via Digitalmars-d-learn
Uranuz: Same situation happens when I assign reference data to properties. Someone has suggested to solve this problem with an attribute, like owned, that forbids to return mutable reference data owned by a class/struct instance. Bye, bearophuile

Re: attribute length missing in std.array: Appender

2014-11-28 Thread bearophile via Digitalmars-d-learn
several lazy items to a dynamic array? This doesn't work: void main() { import std.array, std.range; int[] arr; arr.put(only(1, 2, 3)); } Bye, bearophile

Dynamic array head const in library code?

2014-11-28 Thread bearophile via Digitalmars-d-learn
[] = 1; HeadConst!int c = arr; HeadConst!int d; arr = d; // fail } Bye, bearophile

Re: Dynamic array head const in library code?

2014-11-28 Thread bearophile via Digitalmars-d-learn
, bearophile

Re: attribute length missing in std.array: Appender

2014-11-28 Thread bearophile via Digitalmars-d-learn
performance a little). But I'd call it extend as in Python. Bye, bearophile

Re: 'int' is enough for 'length' to migrate code from x86 to x64

2014-11-27 Thread bearophile via Digitalmars-d
Kagamin: You can't change coding practice by introducing a new type. We can try to change coding practice introducing new types :-) Bye, bearophile

Re: Uninitialized object hangs without warning.

2014-11-26 Thread bearophile via Digitalmars-d-learn
the compiler finds the bug: class MyClass { this() {} void someFunction() { //body } } void main() { MyClass classObject; classObject.someFunction; } test.d(11,5): Error: null dereference in function _Dmain But in more complex cases the compiler doesn't. Bye, bearophile

Re: const class

2014-11-26 Thread bearophile via Digitalmars-d-learn
Oleg: how create variable that store const object and can be changed to other const object? Take a look at std.typecons.Rebindable/std.typecons.rebindable. Read all Phobos documentation, it helps. Bye, bearophile

Re: D is for Data Science

2014-11-25 Thread bearophile via Digitalmars-d-announce
a warning if you use the built-in sort and reverse. Unfortunately the library reverse still needs to be fixed to return the array as the built-in reverse. Bye, bearophile

Re: 'int' is enough for 'length' to migrate code from x86 to x64

2014-11-25 Thread bearophile via Digitalmars-d
unsigned types. I think the intention probably was to improve on the C situation, where there is undefined behaviour that really should be defined. But do we really want to preclude ever having overflow checking for integers? +1 Bye, bearophile

Re: A nice D coding pattern

2014-11-25 Thread bearophile via Digitalmars-d-learn
MattCoder: May I understand that you're disabling the default constructor of the struct to use your own constructor? Right. So the instance data of the struct is more likely correct when you call its methods. Bye, bearophile

Re: D is for Data Science

2014-11-24 Thread bearophile via Digitalmars-d-announce
Dmitry Olshansky: Why is File.byLine so slow? Seems to be mostly fixed sometime ago. Really? I am not so sure. Bye, bearophile

Re: D is for Data Science

2014-11-24 Thread bearophile via Digitalmars-d-announce
Dmitry Olshansky: Which is 1:1 parity. Another myth busted? ;) There is still an open bug report: https://issues.dlang.org/show_bug.cgi?id=11810 Do you want also to benchmark that byLineFast that for me is usually significantly faster than the byLine? Bye, bearophile

Testing lazy ranges in post-conditions

2014-11-24 Thread bearophile via Digitalmars-d
{ return iota(5); } void main() {} This limits the usefulness of post-conditions in my code. Do you have ideas to solve this problem? Bye, bearophile

Re: Testing lazy ranges in post-conditions

2014-11-24 Thread bearophile via Digitalmars-d
= b.length == 2)); } body { auto a = new int[10]; return a.chunks(2); } void main() {} Bye, bearophile

Re: Testing lazy ranges in post-conditions

2014-11-24 Thread bearophile via Digitalmars-d
to consume the result in a post-condition check that doesn't consume it. I agree. Bye, bearophile

Re: projections in D

2014-11-24 Thread bearophile via Digitalmars-d-learn
too. Bye, bearophile

Re: projections in D

2014-11-24 Thread bearophile via Digitalmars-d-learn
). The eager version creates an array of the results in heap memory. Bye, bearophile

Something between a scalar and an enum

2014-11-24 Thread bearophile via Digitalmars-d-learn
doesn't offer me much good to express this idiom, but I am not sure how much a type system can help here even in principle. Bye, bearophile

A nice D coding pattern

2014-11-24 Thread bearophile via Digitalmars-d-learn
. And the @disable this() assures that a struct is correctly initialized by the constructor. This pattern has significant advantages regarding code reliability. You can see an example of this pattern that I've used here: http://rosettacode.org/wiki/Solve_a_Hopido_puzzle#D Bye, bearophile

Re: 'int' is enough for 'length' to migrate code from x86 to x64

2014-11-21 Thread bearophile via Digitalmars-d
? Bye, bearophile

Re: Why is `scope` planned for deprecation?

2014-11-21 Thread bearophile via Digitalmars-d
Walter Bright: Except that isn't really quicksort. Monads are the workaround functional languages use to deal with things that need mutation. Take also a look at Clean language. It doesn't use monads and it's a very efficient functional language. Bye, bearophile

Re: 'int' is enough for 'length' to migrate code from x86 to x64

2014-11-21 Thread bearophile via Digitalmars-d
Daniel Murphy: void fun(int[] a) { foreach_reverse(i, 0...a.length) { } } Better (it's a workaround for a D design flaw that we're unwilling to fix): foreach_reverse(immutable i, 0...a.length) Bye, bearophile

Re: 'int' is enough for 'length' to migrate code from x86 to x64

2014-11-21 Thread bearophile via Digitalmars-d
Walter Bright: I thought everyone hated foreach_reverse! I love it! Bye, bearophile

Re: 'int' is enough for 'length' to migrate code from x86 to x64

2014-11-21 Thread bearophile via Digitalmars-d
is to have immutable on default and mutable on request. If D doesn't have this quality, better to add immutable every damn time). Bye, bearophile

Re: Comparing Parallelization in HPC with D, Chapel, and Go

2014-11-21 Thread bearophile via Digitalmars-d
floating point benchmarks there's a huge difference between LDC2 and DMD). Bye, bearophile

Re: Comparing Parallelization in HPC with D, Chapel, and Go

2014-11-21 Thread bearophile via Digitalmars-d
Kapps: The flags make it likely that DMD was used (-O -inline -release). But I use ldmd2 all the time with those arguments :-) Bye, bearophile

Re: Ranges and Exception handling PR 2724

2014-11-20 Thread bearophile via Digitalmars-d
(no exceptions are involved): https://issues.dlang.org/show_bug.cgi?id=6840 See also: https://issues.dlang.org/show_bug.cgi?id=6843 Bye, bearophile

Re: 'int' is enough for 'length' to migrate code from x86 to x64

2014-11-20 Thread bearophile via Digitalmars-d
Walter Bright: If that is changed to a signed type, then you'll have a same-only-different set of subtle bugs, This is possible. Can you show some of the bugs, we can discuss them, and see if they are actually worse than the current situation. Bye, bearophile

Re: write multiple lines without \n with writeln

2014-11-20 Thread bearophile via Digitalmars-d-learn
uri: It's by design And it's a nice handy design. Bye, bearophile

Re: Compiler error with slices, .dup and ref Parameter

2014-11-20 Thread bearophile via Digitalmars-d-learn
an ER for it, and otherwise to add the little diagnostic ER it to Bugzilla. Bye, bearophile

Re: write multiple lines without \n with writeln

2014-11-20 Thread bearophile via Digitalmars-d-learn
compile and run this program: void main() { import std.stdio; writeln( first string second ~ string ); } I see this output (and it's correct, as expected): first stringsecondstring Bye, bearophile

Re: Clock.currTime

2014-11-20 Thread bearophile via Digitalmars-d-learn
Kent: I am reading the book 《D Cookbook》 In Page 36,this code can't be complied: auto filtered = filter!((a) = Clock.currTime() - a.timeLastModified 14.days)(sorted); Perhaps: mySorted.filter!(a = Clock.currTime - a.timeLastModified 14.days); Bye, bearophile

Re: 'int' is enough for 'length' to migrate code from x86 to x64

2014-11-19 Thread bearophile via Digitalmars-d
/ulong. I don't agree with this design decision, but it's unlikely that Walter has changed his mind on it. So better to go on and discuss other things more likely to happen. Bye, bearophile

Re: 'int' is enough for 'length' to migrate code from x86 to x64

2014-11-19 Thread bearophile via Digitalmars-d
workarounds (or to use better designed languages. But no language is perfect). Bye, bearophile

Rust lifetimes and collections [OT]

2014-11-19 Thread bearophile via Digitalmars-d
work with x } That's all perfectly sound and good, but it's wasting tons of time doing bounds checking! It's also totally unidiomatic. This is nice: fn split_at_mut(mut self, mid: uint) - (mut [T], mut [T]); Bye, bearophile

Re: 'int' is enough for 'length' to migrate code from x86 to x64

2014-11-19 Thread bearophile via Digitalmars-d
even if you just compare (with ) a length with a signed value. Bye, bearophile

Re: 'int' is enough for 'length' to migrate code from x86 to x64

2014-11-19 Thread bearophile via Digitalmars-d
Andrei Alexandrescu: No. -- Andrei Yet, experience in D has shown very well that having unsigned lengths is the wrong design choice. It's a D wart. Bye, bearophile

Re: 'int' is enough for 'length' to migrate code from x86 to x64

2014-11-19 Thread bearophile via Digitalmars-d
is saying that a system language should not have unsigned values. The discussion here is about the type of array lengths. Bye, bearophile

Re: Rust lifetimes and collections [OT]

2014-11-19 Thread bearophile via Digitalmars-d
, without going to full manual formal proof, that is an excessive burden for most cases for most programmers. Bye, bearophile

Re: size_t for length on x64 will make app slower than on x86?

2014-11-18 Thread bearophile via Digitalmars-d
Marco Leise: foreach (i; 0 .. a.length) { somework(); } Better: foreach (immutable _; 0 .. a.length) { somework(); } Unfortunately this syntax is not yet supported, for unknown reasons: foreach (; 0 .. a.length) { somework(); } Bye, bearophile

Re: Overloading struct members (or cast?)

2014-11-18 Thread bearophile via Digitalmars-d-learn
Wsdes: union value { const char *string; } Try: union Value { const char* myString; } Note the upper caseing, the spacing after the star, and the string name replaced with something else. Bye, bearophile

Re: Why is `scope` planned for deprecation?

2014-11-13 Thread bearophile via Digitalmars-d
programmers and language implementators) than the Rust solution. Bye, bearophile

Re: Microsoft now giving away VS 2013

2014-11-13 Thread bearophile via Digitalmars-d
Wyatt: So, how to write a source-to-source compiler from CS to D…? ;-) I think it would be more useful would be to go the other way around for targeting Windows Phone. Perhaps it's better to make LDC2-LLVM output the intermediate code of the dotnet :-) Bye, bearophile

Re: Callbacks in D as void functions

2014-11-13 Thread bearophile via Digitalmars-d-learn
Wsdes: The wiki says that callback functions should be declared as integer functions, What's bad in returning void? Bye, bearophile

Re: Why is `scope` planned for deprecation?

2014-11-11 Thread bearophile via Digitalmars-d
difficulties, is it possible to ask for help to one of the persons that designed (or watched closely design) the similar thing for Rust? Bye, bearophile

Re: How to use map?

2014-11-11 Thread bearophile via Digitalmars-d-learn
, std.array; float[] vals = [1.1, 2.1, 3.1, 4.1]; auto arr = vals.map!(Foo!float).array; arr.writeln; } Bye, bearophile

Re: sortOn: sorts range of aggregates by member name(s)

2014-11-10 Thread bearophile via Digitalmars-d
, bearophile

Found by Coverty in LibreOffice

2014-11-10 Thread bearophile via Digitalmars-d
=c61b200fb0130f0b0f9f51b48e3799625b83 Bye, bearophile

Re: Keeping a dynamic sorted range

2014-11-10 Thread bearophile via Digitalmars-d
Andrei Alexandrescu: One possibility is a function sortedChain that takes two or more sorted ranges and returns a lazy sorted range. -- Andrei Perhaps you are answering another thread and another problem. In this problem there is only one range. Bye, bearophile

Re: Found by Coverty in LibreOffice

2014-11-10 Thread bearophile via Digitalmars-d
new Exception(Bad); else { static assert(is(typeof(y) == Natural)); return x / y; } } In Whiley inside the else branch the _type_ of y is different. Bye, bearophile

Re: DIP68: Adding @nogc to types

2014-11-10 Thread bearophile via Digitalmars-d
Tomer Filiba: http://wiki.dlang.org/DIP68 Perhaps your DIP also needs a trait? struct Foo {} @nogc struct Bar {} static assert(!__traits(hasNogc, Foo)); static assert(__traits(hasNogc, Bar)); Byem bearophile

Re: Keeping a dynamic sorted range

2014-11-10 Thread bearophile via Digitalmars-d
Andrei Alexandrescu: http://dlang.org/phobos/std_algorithm.html#.setUnion That's right! -- Andrei Still, this is very far from what I asked for... Bye, bearophile

Re: DIP68: Adding @nogc to types

2014-11-10 Thread bearophile via Digitalmars-d
Jacob Carlborg: Don't we have something for that already? Do you mean we already have a trait for a feature that doesn't yet exists? :-) Bye, bearophile

Re: status of D optimizers benefiting from contracts ?

2014-11-10 Thread bearophile via Digitalmars-d-learn
the complexity, it just increases the confusion. I greatly prefer when things with different semantics have cleanly distinct names. Bye, bearophile

Re: Instructions for compilation from multiple source files

2014-11-10 Thread bearophile via Digitalmars-d-learn
the same if you want to create a lib): dmd a.d b.d Otherwise you can also use ddmd and let it find the module dependencies by itself. Bye, bearophile

Re: Strictness of language styling

2014-11-10 Thread bearophile via Digitalmars-d-learn
: http://dlang.org/dstyle.html Bye, bearophile

Re: Memory usage of dmd

2014-11-10 Thread bearophile via Digitalmars-d-learn
Xavier Bigand: So for the moment I build the web site on a physical machine, and I saw the compilation takes around 1.6Go of memory. Compiling the whole Phobos as a single compilation unit on 32 bit DMD requires a little more than 1 GB. Bye, bearophile

Re: convert static arrays to dynamic arrays and return, have wrong data.

2014-11-09 Thread bearophile via Digitalmars-d
convert static arrays to dynamic arrays. Yeah, what do you suggest to change in the language to avoid this problem? Bye, bearophile

Re: How to let D's one module contains lots of classes.

2014-11-09 Thread bearophile via Digitalmars-d
AlanThinker: If there all classes in one file, the file will be to big. The file will also probably contain several free functions, and not just classes. Bye, bearophile

Re: convert static arrays to dynamic arrays and return, have wrong data.

2014-11-09 Thread bearophile via Digitalmars-d
that kind of operations indiscriminately, you reduce a lot the usefulness of D (because fixed size = dynamic slice array is a conversion useful in many cases) and probably force the introduction of many casts, and I don't know if this will increase the overall safety of the D code. Bye, bearophile

Re: sortOn: sorts range of aggregates by member name(s)

2014-11-09 Thread bearophile via Digitalmars-d
!(fieldGetter(field1, field2)); Bye, bearophile

Re: status of D optimizers benefiting from contracts ?

2014-11-09 Thread bearophile via Digitalmars-d-learn
Laeeth Isharc: Walter Bright suggests that a supplementary benefit of using contrats is helping the compiler make optimisations. I think no D compilers do this, currently. And no one knows when such things will be added, if ever. Bye, bearophile

Re: status of D optimizers benefiting from contracts ?

2014-11-09 Thread bearophile via Digitalmars-d-learn
, bearophile

Re: status of D optimizers benefiting from contracts ?

2014-11-09 Thread bearophile via Digitalmars-d-learn
H. S. Teoh: It's only a bad idea because people abuse assert() where it's not appropriate. It's a bad idea because Walter seems unable to understand the difference between verifying and proving. Bye, bearophile

Re: Cast to left hand side

2014-11-09 Thread bearophile via Digitalmars-d-learn
; } Bye, bearophile

Re: joiner random access range?

2014-11-09 Thread bearophile via Digitalmars-d-learn
This was Issue 8405 opened by Jonathan M Davis two years ago, I have added my use cases: https://issues.dlang.org/show_bug.cgi?id=8405 Bye, bearophile

Re: Keeping a dynamic sorted range

2014-11-08 Thread bearophile via Digitalmars-d
working on it... In most cases a built-in dynamic array is fine. Once in a while you want to use an std.array.Array. When they are not enough, I use a sorted tree or something else. Bye, bearophile

joiner random access range?

2014-11-08 Thread bearophile via Digitalmars-d-learn
can have arbitrary many rows. chain(m[0], m[1]).sort(); m.joiner.writeln; } Is it possible and reasonable for joiner to return a random access range in such cases (where the input is a random access range of random access ranges), so I can sort its items? Bye, bearophile

Keeping a dynamic sorted range

2014-11-07 Thread bearophile via Digitalmars-d
; } SortedRange!(Foo[], q{ a.x b.x }) data; data ~= Foo(5); immutable n = data.upperBound(Foo(2)).length; Bye, bearophile

Re: Keeping a dynamic sorted range

2014-11-07 Thread bearophile via Digitalmars-d
very fast binary searches, unlike a heap). So what solution do you suggest? A pair of functions that work on a sorted container of that type for Phobos? Bye, bearophile

Re: Keeping a dynamic sorted range

2014-11-07 Thread bearophile via Digitalmars-d
. Generally it's better to not use a more complex data structure if a simpler one suffices. Bye, bearophile

Re: Keeping a dynamic sorted range

2014-11-07 Thread bearophile via Digitalmars-d
to use an assumeSorted(). This is not good. Bye, bearophile

Re: transversal sum

2014-11-07 Thread bearophile via Digitalmars-d-learn
!(a = a.sum); Bye, bearophile

Re: Multiple Inhertiance?

2014-11-06 Thread bearophile via Digitalmars-d
alias this much). Bye, bearophile

Re: Multiple Inhertiance?

2014-11-06 Thread bearophile via Digitalmars-d
, and little else). Bye, bearophile

Re: Share array element between threads

2014-11-06 Thread bearophile via Digitalmars-d-learn
(classInstanceSize, Foo)); pragma(msg, __traits(classInstanceSize, Bar)); } Output: 12u 8u Bye, bearophile

Re: sortOn: sorts range of aggregates by member name(s)

2014-11-05 Thread bearophile via Digitalmars-d
Marc Schütz: r.sortBy!(a = a.norm); r.schwartzSort!(a = a.norm); Bye, bearophile

Re: sortOn: sorts range of aggregates by member name(s)

2014-11-05 Thread bearophile via Digitalmars-d
Nordlöw: Ok, but this doesn't support multi-sorting, right? If performance is not a top priority, you can use a tuple: r.schwartzSort!(x = tuple(x.a, x.b, x.c)); Bye, bearophile

Re: std.concurrency.Generator yieldAll?

2014-11-05 Thread bearophile via Digitalmars-d
well-behaving guarantees. Bye, bearophile

Re: Multiple Inhertiance?

2014-11-05 Thread bearophile via Digitalmars-d
designers don't want it to be easy to do. And this is good. Bye, bearophile

Re: Access Violation Tracking

2014-11-05 Thread bearophile via Digitalmars-d-learn
those asserts. Bye, bearophile

Re: Curiously Cyclic Template Pattern causes segfault?

2014-11-05 Thread bearophile via Digitalmars-d-learn
Justin Whear: --any compiler crash is a bug regardless of whether the source is valid D code or not. I suspect that in some cases those compiler crashes are a way for the compiler to tell the programmer that the code was too much hairy and too much hard to understand ;-) Bye, bearophile

isRangeOf ?

2014-11-04 Thread bearophile via Digitalmars-d-learn
Sometimes I have a function that needs an iterable: void foo(Range)(Range data) if (isForwardRange!Range is(Unqual!(ForeachType!Range) == int)) {} So is it a good idea to add a isRangeOf template to Phobos? void foo(Range)(Range data) if (isRangeOf!(Range, int)) {} Bye, bearophile

Re: isRangeOf ?

2014-11-04 Thread bearophile via Digitalmars-d-learn
). I have opened an ER: https://issues.dlang.org/show_bug.cgi?id=13682 Bye, bearophile

Re: The interface's 'in' contract passes if it makes a virtual function call

2014-11-04 Thread bearophile via Digitalmars-d-learn
Ali Çehreli: Perhaps I am expecting too much from the current 'in' contract design and implementation. ;) The in contract is named pre-condition, or precondition. Bye, bearophile

Re: Programming Language for Games, part 3

2014-11-03 Thread bearophile via Digitalmars-d
the full information themselves (note: this is how science works in laboratories). Bye, bearophile

Re: Programming Language for Games, part 3

2014-11-02 Thread bearophile via Digitalmars-d
. It is memory safe. Probably that's why there are two kind of casts in Haskell. Bye, bearophile

Re: Programming Language for Games, part 3

2014-11-02 Thread bearophile via Digitalmars-d
the faults are more acceptable than the known alternatives. I think the free mixing of signed and unsigned integral values is not a good idea in D. I think that there are various ways to refine immutable value range propagation. Bye, bearophile

Re: Programming Language for Games, part 3

2014-11-02 Thread bearophile via Digitalmars-d
Andrei Alexandrescu: Is that a best-effort kind of approach? If so, that would be pretty bad... I don't exactly know how that Rust macro works, sorry, I am still rather ignorant about Rust. Bye, bearophile

More flexible sorted ranges?

2014-11-02 Thread bearophile via Digitalmars-d-learn
. Is this possible and a good idea to do? Bye, bearophile

Re: More flexible sorted ranges?

2014-11-02 Thread bearophile via Digitalmars-d-learn
Ola Fosheim Grøstad: Shouldn't sorted range maintain the invariant automatically in order to remain typesafe? Yes, of course. Bye, bearophile

<    1   2   3   4   5   6   7   8   9   10   >