Re: [OT] Swift removing minor features to piss me off

2016-04-29 Thread bearophile via Digitalmars-d
I think Swift is not yet stable. So if you want to use it you have to deal with language changes (D2 is stable). In a modern language ++ and -- are OK only if they return void. Otherwise they are bug-prone and allow people to write less readable code. C for() loops are powerful, but a bit

Re: final switch and straight integers

2016-04-20 Thread bearophile via Digitalmars-d
Dominikus Dittes Scherkl: final switch makes no sense on things that are not enumerated. Even on ubyte almost nobody will ever list all 256 cases, not to mention larger types. It's easy to cover all the values in a switch, using ranges. No need to forbid final switch for integral values. It

Re: D vs Rust

2016-03-14 Thread bearophile via Digitalmars-d
gour: For quite some time I was looking at Ada as potential language to write multi-platform desktop application, but, being the big language which requires lot of time and energy to invest into learning/mastering it, I, somehow, feel reluctant seeing that there is practically no open-source

Re: D vs Rust

2016-02-01 Thread bearophile via Digitalmars-d
xenon325: Doesn't http://wiki.dlang.org/DIP25 fix this ? I think DIP25 is designed to be only a partial solution, it's not a complete memory safety story. Bye, bearophile

Re: D vs Rust

2016-01-31 Thread bearophile via Digitalmars-d
On Sunday, 31 January 2016 at 15:44:37 UTC, Laeeth Isharc wrote: Guillaume Piolat "- D is a large language, not sure how much relatively to Rust. I've heard Rust is complicated too." and yet, it's easy to get started if you know C. one can be quite quickly productive without having any

Re: D vs Rust

2016-01-30 Thread bearophile via Digitalmars-d
Laeeth Isharc: On Saturday, 30 January 2016 at 16:51:09 UTC, Laeeth Isharc wrote: I haven't used Ocaml, but was intrigued by it after seeing Yaron Minsky's talks. To what extent can pattern matching, strong types with invariants and other things Ocaml features be implemented idiomatically in

Re: D vs Rust

2016-01-29 Thread bearophile via Digitalmars-d
qznc: On Friday, 29 January 2016 at 09:00:52 UTC, qznc wrote: D is a broader language and is applicable in more situations. In many cases you don't care and don't want to care about memory management. Learning to manage memory in Rust takes lot of time and practice, it's a bit painful. I am

Re: Can D interface with Free Pascal?

2016-01-28 Thread bearophile via Digitalmars-d-learn
FreeSlave: On Thursday, 28 January 2016 at 08:15:38 UTC, FreeSlave wrote: Not directly. You can declare cdecl function on Free Pascal side and call it as extern(C). What about extern(Pascal)? https://dlang.org/spec/attribute.html#linkage Bye, bearophile

Re: How to represent struct with trailing array member

2016-01-21 Thread bearophile via Digitalmars-d-learn
Dibyendu Majumdar: On Thursday, 21 January 2016 at 21:52:06 UTC, Dibyendu Majumdar wrote: How should this be translated to D? Will D's array access allow data elements to be accessed beyond the size declared? Take a look at the code I've written here:

Re: Convert some ints into a byte array without allocations?

2016-01-16 Thread bearophile via Digitalmars-d-learn
Yazan D: On Saturday, 16 January 2016 at 14:42:27 UTC, Yazan D wrote: ubyte[] b = (cast(ubyte*) )[0 .. int.sizeof]; Better to use the actual size: ubyte[] b = (cast(ubyte*) )[0 .. a.sizeof]; Bye, bearophile

Re: Under 1000 opened bugs for Phobos

2015-12-02 Thread bearophile via Digitalmars-d
BBaz: So I don't know...and I ask, should the garbages from bearophile be closed ? Hello, I use D every day, and there are several functions that I'd like in Phobos. I think all/most of them can be of general usefulness. While I am often wrong, those ERs come from plenty of experience

Re: conver BigInt to string

2015-11-05 Thread bearophile via Digitalmars-d-learn
Namal: Hello I am trying to convert BigInt to string like that while trying to sort it: void main() { import std.stdio, std.algorithm, std.conv, std.bigint, std.string; auto n = 17.BigInt ^^ 179; n.text.dup.representation.sort().release.assumeUTF.writeln; } Bye, bearophile

Re: conver BigInt to string

2015-11-05 Thread bearophile via Digitalmars-d-learn
void main() { import std.stdio, std.algorithm, std.conv, std.bigint, std.string; auto n = 17.BigInt ^^ 179; n.text.dup.representation.sort().release.assumeUTF.writeln; } Better: n.to!(char[]).representation.sort().release.assumeUTF.writeln; Bye, bearophile

Re: array function

2015-08-31 Thread bearophile via Digitalmars-d-learn
Namal: std::vector foo(int N){ std::vector V(N); int some_array[N]; VLAs are not present in D. Bye, bearophile

[Rosettacode] sum of powers conjecture

2015-07-26 Thread bearophile via Digitalmars-d-learn
I've translated the C++ entry to D as third D entry, but it's not a good translation, I've just converted iterators to pointers instead of using ranges (the resulting speed is acceptable). You're welcome to improve it:

Re: a success story for D ! !!

2015-05-05 Thread bearophile via Digitalmars-d
ponce: Paper: http://vlang.org/dvcon2014.pdf I'd say that's pretty huge! Very nice. Bye, bearophile

Re: Ada to D - an array for storing values of each of the six bits which are sufficient

2015-05-01 Thread bearophile via Digitalmars-d-learn
Dennis Ritchie: Anybody can write a packed array on the D? I once badly represent the means by which we can write a packed array. Maybe for this you should use core.simd or unions? SIMD could be useful for some fancy bulk operations. But you should be able to write a good basic packed array

Re: Ada to D - an array for storing values of each of the six bits which are sufficient

2015-04-30 Thread bearophile via Digitalmars-d-learn
Dennis Ritchie: There is an array of values to store each of which sufficiently 6 bits. As it is written down on the D? You can't do it directly in D. Someone has to write a packed array data structure to do it. Bye, bearophile

Re: if(arr) now a warning

2015-04-30 Thread bearophile via Digitalmars-d
Andrei Alexandrescu: I have no doubt the change can find certain errors. Problem is false positives. FWIW these are the changes I had to operate on std.allocator to make it work with the new compiler. One per 194 lines on average, all false positives: Just fix your code Andrei Alexandrescu

Re: Implicit conversion error

2015-04-30 Thread bearophile via Digitalmars-d-learn
Paul: When compiled on a 64 bit machine, this line int r = uniform(0, mobs.length); .length returns a size_t, and 0 is an int. uniform() probably decides to unify those types to a size_t. A size_t is 32 bit on 32 bit machines and 64 bits on 64 bit machines. But D int is always a 32 bit

Re: if(arr) now a warning

2015-04-29 Thread bearophile via Digitalmars-d
Steven Schveighoffer: FYI, Andrei and Walter are reversing this change barring any new evidence it's helpful to people. Please speak up if you disagree. There's no more evidence. It's an improvement, for people coming from Python. The current semantics is not meaningful. One of the points

Re: [hackathon] An article about metaprogramming

2015-04-29 Thread bearophile via Digitalmars-d
Mafi: https://marfisc.wordpress.com/2015/04/29/using-d-templates-for-gamedev/ What do you think? Any remarks? The SDL_Event is a union. Accessing it is inherently unsafe for type consistency and memory safety. The SDL library mitigates this problem by adding a tag (the member type) which

Re: Possible to write a classic fizzbuzz example using a UFCS chain?

2015-04-28 Thread bearophile via Digitalmars-d-learn
Gary Willoughby: I wondered if it was possible to write a classic fizzbuzz[1] example using a UFCS chain? I've tried and failed. Is this OK? void main() { import std.stdio, std.algorithm, std.range, std.conv, std.functional; 100 .iota .map!(i = ((i + 1) % 15).predSwitch(

Re: C++ const expression are not that const after all

2015-04-28 Thread bearophile via Digitalmars-d
Luc Bourhis: The author of that blog seems to see his finding in a positive light actually. As it makes it possible to write more powerful template metaprograms! One of the essences of modern languages is to restrict the power of the programmer in specific parts, to reduce unwanted

Re: function ref param vs pointer param

2015-04-24 Thread bearophile via Digitalmars-d-learn
On Friday, 24 April 2015 at 13:39:35 UTC, ref2401 wrote: processPointer(ms); I think doing this way is more descriptive. Now all readers know that ms might be changed inside the function. C# avoids that problem requiring (in most cases) the usage of ref at the calling point too. But this

Re: function ref param vs pointer param

2015-04-24 Thread bearophile via Digitalmars-d-learn
ref2401: void processRef(ref MyStruct ms) { writeln(processRef: , ms); } void processPointer(MyStruct* ms) { writeln(processPointer: , *ms); ref params don't need the * every time you use them inside the function, and don't need the when you call the function. Bye,

Re: switch case expressions

2015-04-23 Thread bearophile via Digitalmars-d
Martin Krejcirik: So, should the case b compile or not ? Is the spec too restrictive here, or is it a bug ? Apparently it's a WONTFIX mess. The spec should be updated. WalterAndrei refused to fix a design bug here. Bye, bearophile

Re: Cleaned up C++

2015-04-23 Thread bearophile via Digitalmars-d
Walter Bright: On 4/22/2015 2:58 PM, bearophile wrote: D is less stack-friendly than Ada (and probably Rust too), ?? In Ada standard library you have safe fixed-size stack-allocated associative arrays. In D you can't even allocate safely a dynamically-sized 1D array on the stack, and

Re: Cleaned up C++

2015-04-22 Thread bearophile via Digitalmars-d
weaselcat: On Wednesday, 22 April 2015 at 19:29:08 UTC, Walter Bright wrote: D is just another of those “Let's put everything on the heap”-languages that do then of course need GC. what's up with people constantly equating garbage collection to being the same as java? In D you don't put

Re: multiSort for sorting AA by value

2015-04-21 Thread bearophile via Digitalmars-d-learn
Chris: I'm happy with it, but maybe there is a more concise implementation? This is a bit shorter and a bit better (writefln is not yet able to format tuples nicely): void main() { import std.stdio: writeln; import std.algorithm.sorting: multiSort; import std.array: array;

Re: Structural exhaustive matching

2015-04-21 Thread bearophile via Digitalmars-d-learn
Jadbox: I'm curious on what the best way to do ADTs in D. Sometimes there's no best way, there are several alternative ways with different tradeoffs. D isn't a functional language and there's no really good way to do ADTs in D. You can use plus a final switch. Or you can use Algebraic from

Re: Vectorization examples

2015-04-20 Thread bearophile via Digitalmars-d
Walter Bright: Use arrays of double2, float4, int4, etc., declared in core.simd. Those will be aligned appropriately. Is the GC able to give memory aligned to 32 bytes for new architectures with 512 bits wide SIMD? and a way to tell the type system that some array slices are fully

Re: D vs nim

2015-04-20 Thread bearophile via Digitalmars-d
Russel Winder: it is all part of guerilla marketing undertaken by anyone with anything to market. It's still not a correct behavour, regardless how many do it. Bye, bearophile

Vectorization examples

2015-04-20 Thread bearophile via Digitalmars-d
Utilizing the other 80% of your system's performance: Starting with Vectorization by Ulrich Drepper: https://www.youtube.com/watch?v=DXPfE2jGqg0 It shows two still missing parts of the D type system: a way to define strongly typed byte alignments for arrays (something better than the

Re: Converting Java code to D

2015-04-20 Thread bearophile via Digitalmars-d-learn
John Colvin: struct LineStyle { enum NONE = None; enum SOLID = Solid; enum DASH = Dash; enum DOT = Dot; enum DASHDOT = Dash Dot; enum DASHDOTDOT = Dash Dot Dot; string label; private this(string label) { this.label = label; } } The constructor

Re: How about appender.put() with var args?

2015-04-16 Thread bearophile via Digitalmars-d
Márcio Martins: app.put(foo); app.put(var); app.put(bar); I'd like put() to accept a lazy range... Bye, bearophile

Re: Programming languages and performance

2015-04-14 Thread bearophile via Digitalmars-d
weaselcat: It's reddit, that's not really surprising. Do you know a place better than Reddit for general programming discussions? The lambda the ultimate blog is not generic. Bye, bearophile

Re: Does 'D' language supports 'C' like VLA?

2015-04-14 Thread bearophile via Digitalmars-d
John Colvin: The problem is that the size isn't necessarily known. The size is generally known only at run-time, that's the point. I guess the compiler could put in a branch, but at that point you'd probably want to give the programmer control and have a way of making it explicit. You

Re: Programming languages and performance

2015-04-14 Thread bearophile via Digitalmars-d
Walter Bright: Algorithms don't actually do deforestation or fusion. The magic happens in how the algorithm is implemented, i.e. the elements are created lazily (on demand) rather than eagerly. Stream fusion is often about laziness. There is a ton of literature about this topic. Bye,

Re: Does 'D' language supports 'C' like VLA?

2015-04-13 Thread bearophile via Digitalmars-d
Steven Schveighoffer: It's very unlikely this will make it into the language. Alloca should be good enough for this, it's not a very common usage, and supporting it is not easy. alloca is bug-prone and unsafe, and if you want to create a 2D array on the stack it's not good enough. They are

Re: DIP77 - Fix unsafe RC pass by 'ref'

2015-04-12 Thread bearophile via Digitalmars-d
Marc Schütz: You have to keep in mind that this is opt-in; it only applies to `scope` variables. I would agree that as a default, it wouldn't fit D at all. I think that, for all its usefulness, it'd be a tad too limiting for my taste if I were forced to use it everywhere. I think D Zen

Re: Function name from function pointer

2015-04-11 Thread bearophile via Digitalmars-d-learn
Paul D Anderson: Is there a way to return the name of a function (a string) from a pointer to that function? Perhaps creating a string[void*] AA and initializing with all the function pointers you care about. Bye, bearophile

Re: if(arr) now a warning

2015-04-09 Thread bearophile via Digitalmars-d
Steven Schveighoffer: What do you think? I asked for this fix almost five years ago, so I think it's about time :-) Bye, bearophile

Re: Generating all combinations of length X in an array

2015-04-09 Thread bearophile via Digitalmars-d-learn
wobbles: Have just tested, it is! But with the current D front-end it's not a good idea to generate too many combinations at compile-time. Efficient code doesn't save you from bad usages. Bye, bearophile

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

2015-04-09 Thread bearophile via Digitalmars-d-learn
Jack Applegame: writeln(a.find(4).empty ? No : Yes); canFind? Bye, bearophile

Re: Generating all combinations of length X in an array

2015-04-08 Thread bearophile via Digitalmars-d-learn
wobbles: While trying to generate all combinations of length X in an array, I came across the question on stackoverflow. [1] Theres a couple good answers there, but one that caught my eye shows a C# code snippet that is quite nice and short: Often short code is not the best code. Take a

Re: Implementing Iterator to support foreach

2015-04-08 Thread bearophile via Digitalmars-d-learn
tcak: I am planning to implement Iterator class. But looking at foreach statement, it takes a range only. Unless you are just experimenting, it's better to not go against a language and its std lib. Bye, bearophile

Re: Why I'm Excited about D

2015-04-08 Thread bearophile via Digitalmars-d
deadalnix: foreach (name; names.parallel) { name.writeln; } no.please I think foo.writeln; is acceptable. You just need to get a bit used to it. Bye, bearophile

Re: function shadowed

2015-04-08 Thread bearophile via Digitalmars-d-learn
ddos: same behavior when overriding methods of base classes This is by design. Bye, bearophile

Re: DIP76: Autodecode Should Not Throw

2015-04-07 Thread bearophile via Digitalmars-d
Vladimir Panteleev: std.conv doesn't return NaN if you try to convert banana to a double. I have suggested to add a nothrow function like maybeTo that returns a Nullable result. Bye, bearophile

Re: Shall I use immutable or const while passing parameters to functions

2015-04-07 Thread bearophile via Digitalmars-d-learn
tcak: void dataProcessor( string giveMeAllYourData ){} dataProcessor( cast( immutable )( importantData[5 .. 14] ) ); With Const, void dataProcessor( in char[] giveMeAllYourData ){} dataProcessor( cast( const )( importantData[5 .. 14] ) ); Don't cast to const/immutable unless you have a

Re: Fun project - faster associative array algorithm

2015-04-07 Thread bearophile via Digitalmars-d
w0rp: It doesn't amaze me at the moment, as it's slightly faster for integers, and slightly slower for strings at the moment. One problem with D strings is that they don't cache their hash value. Bye, bearophile

Re: Fun project - faster associative array algorithm

2015-04-07 Thread bearophile via Digitalmars-d
Andrei Alexandrescu: A possible cache-friendly replacement would be an array of buckets with local probing to resolve collisions. Arrays would need to move data. Current hashtables rely on values staying put. -- Andrei The efficiency behavour of modern CPUs+memory pyramid are rather not

Re: Questions about phobos additions mentioned in 2015H1 vision document

2015-04-05 Thread bearophile via Digitalmars-d
Andrei Alexandrescu: 1. Are you wanting a large batteries included standard library a'la Python[2] or only focused around the aspects mentioned? Batteries included. This is a quite significant decision. It has both advantages and disadvantages. (I think Rust has chosen to have a lighter

Re: Issue with free() for linked list implementation

2015-04-04 Thread bearophile via Digitalmars-d-learn
Namespace: I've written a straight forward linked list implementation here: https://github.com/nomad-software/etcetera/blob/master/source/etcetera/collection/linkedlist.d Even though I'm using the GC to manage memory, maybe it will help you. Good idea to link to some existing code. Here

Re: The next iteration of scope

2015-04-04 Thread bearophile via Digitalmars-d
Walter Bright: I'm not convinced of the need for overloading on 'scope'. Do you want to explain some of the advantages and disadvantages of that? It will help understand your reasons. Bye, bearophile

Re: Benchmark of D against other languages

2015-04-02 Thread bearophile via Digitalmars-d
Martin Nowak: Your persistent interest in integer overflow checks make we wonder if you were responsible for this? http://www.around.com/ariane.html I am not responsible for that, but I try to not be responsible for future molecular biology mistakes equivalent to that Ariane fiasco. Bye,

Re: Benchmark of D against other languages

2015-04-02 Thread bearophile via Digitalmars-d
weaselcat: was it a conscious decision to make the AA [] operator not work like map/etc in C++? What do you mean? accessing a non-existing element in C++'s map/unordered_map inserts the default instead of raising an exception int main(int argc, char *argv[]) {

Re: Benchmark of D against other languages

2015-04-01 Thread bearophile via Digitalmars-d
Andrei Alexandrescu: Oh boy all classes with one-liner non-final methods. Manu must be dancing a gig right now :o). -- Andrei Yes, the right default for D language should be final, because lot of programmers are lazy and they don't add attributes. Bye, bearophile

Re: Speed of horizontal flip

2015-04-01 Thread bearophile via Digitalmars-d-learn
tchaloupka: Am I doing something utterly wrong? If you have to perform performance benchmarks then use ldc or gdc. Also disable bound tests with your compilation switches. Sometimes reverse() is not efficient, I think, it should be improved. Try to replace it with a little function written

Re: Benchmark of D against other languages

2015-04-01 Thread bearophile via Digitalmars-d
Martin Nowak: GCC5 comes with a big announcement about devirtualization. https://www.gnu.org/software/gcc/gcc-5/changes.html#general I have a small question. That page says: A new set of built-in functions for arithmetics with overflow checking has been added: __builtin_add_overflow,

Re: The next iteration of scope

2015-04-01 Thread bearophile via Digitalmars-d
Walter Bright: I'm thinking of a modest step which would be a subset of your proposal: 1. implement 'scope' and 'return' for arrays, classes, and pointers 2. implement inference for templates and lambdas 3. enable it with the -dip25 switch and see how far that takes us. This is

Re: Gary Willoughby: Why Go's design is a disservice to intelligent programmers

2015-03-30 Thread bearophile via Digitalmars-d-announce
Ola Fosheim Grøstad: So, it will just fade way in the sea of JavaScript wannabe replacements. Maybe, but Google is using it for Google Ads. Which is their primary business? Still, a bit early to say what happens next. Perhaps next some kind of blend of Typescript and Dart will become part

Re: What ?

2015-03-30 Thread bearophile via Digitalmars-d-learn
Brian Schott: Do this instead: ulong u = 1L 63; I suggest a more explicit: ulong u = 1UL 63; Alternative: ulong u = 2UL ^^ 63; Bye, bearophile

Re: Adding sets to the language.

2015-03-29 Thread bearophile via Digitalmars-d
w0rp: Every now and then I want a set type, I think you can implement good enough sets in Phobos, do you agree? But you can't do the same with tuples. So I prefer sets in Phobos and tuples in the language. Bye, bearophile

Re: Associative Array of Const Objects?

2015-03-29 Thread bearophile via Digitalmars-d-learn
bitwise: I'm a little confused at this point why this doesn't work either: const and immutable are rather different between C++ and D, I suggest you to take a look at the documentation: http://dlang.org/const-faq.html Bye, bearophile

Re: Associative Array of Const Objects?

2015-03-28 Thread bearophile via Digitalmars-d-learn
bitwise: class Test{} void main() { const(Test)[string] tests; tests[test] = new Test(); } This code used to work, but after upgrading to dmd 2.067, it no longer does. --Error: cannot modify const expression tests[test] How do I insert an item into an associative array of

Re: Why dont dlang check NullPointer?

2015-03-27 Thread bearophile via Digitalmars-d
zhmt: In short words, I want to catch something like NullPointerException. Is this possible? One solution is to add null tests to D in nonrelease mode. A better solution is to modify D to remove all or most chances of dereferencing null pointers and class references. Bye, bearophile

Re: [Phobos] You're crippled by your orthodoxism

2015-03-26 Thread bearophile via Digitalmars-d
Jean pierre: This is a problem, you, the D core has: you're crippled by your orthodoxism. Nothing will be added because of this: **rules**. The current level of acceptance of Phobos patches seems roughly correct to me. Bye, bearophile

Re: D's type classes pattern ?

2015-03-25 Thread bearophile via Digitalmars-d-learn
matovitch: I am curious to know how isInputRange is implemented since I wanted to do kind of the same but I am afraid it's full of (ugly) traits and template trickeries where haskell type classes are quite neat and essentially a declaration of an interface. Take a look at the sources and

Re: Keep Track of the Best N Nodes in a Graph Traversal Algorithm

2015-03-25 Thread bearophile via Digitalmars-d-learn
Nordlöw: I have graph traversal algorithm that needs to keep track of the N best node visit. std.algorithm.topNCopy? Bye, bearophile

Re: C# to D

2015-03-25 Thread bearophile via Digitalmars-d-learn
Dennis Ritchie: int[] arr = { 7, 5, 7, 3, 3, 5, 3, 3, 0, 3, 1, 1, 5, 1, 1, 1, 2, 2, 8, 5, 8, 8 }; Console.WriteLine(string.Join( , arr.OrderByDescending(x = arr.Count(y = y == x)).ThenBy(x = x))); // prints 1 1 1 1 1 3 3 3 3 3 5 5 5 5 8 8 8 2 2 7 7 0 One solution:

Re: C# to D

2015-03-25 Thread bearophile via Digitalmars-d-learn
.schwartzSort!(x = tuple(-arr.count!(y = y == x), x)) But calling count for each item is not efficient (in both C# and D). If your array is largish, then you need a more efficient solution. Bye, bearophile

Re: C# to D

2015-03-25 Thread bearophile via Digitalmars-d-learn
Ali Çehreli: Do you know the story about groupBy? It's a long messy story. Look for it with another name, like chunkBy or something like that. Bye, bearophile

Re: C# to D

2015-03-25 Thread bearophile via Digitalmars-d-learn
Ivan Kazmenko: (1) For me, the name of the function is obscure. Something like sortBy would be a lot easier to find than schwartzSort. I've asked to change the name of that function for years. But Andrei Alexandrescu is a adamantly against changing that pet name he has chosen. This is

Re: C# to D

2015-03-25 Thread bearophile via Digitalmars-d-learn
Dennis Ritchie: A more effective solution for C ++: #include iostream #include vector #include range/v3/all.hpp int main() { using namespace ranges; auto rng = istreamint( std::cin ) | to_vector | action::sort | view::group_by( std::equal_toint() )

Re: Gary Willoughby: Why Go's design is a disservice to intelligent programmers

2015-03-25 Thread bearophile via Digitalmars-d-announce
Ola Fosheim Grøstad: Downplaying other languages makes the D crowd look desperate... That kind of articles are bad for the image of the D community (and the D code shown in that article is not the best). Bye, bearophile

Re: C# to D

2015-03-25 Thread bearophile via Digitalmars-d-learn
Ivan Kazmenko: arr.map !(to !(string)) .join ( ) .writeln; I suggest to not put a space before the bang (!), because it's confusing for me. Also, arr.map !(to !(string)) is better written arr.map!text. But even better is to use the range formatting of writefln,

Re: uniform tuple syntax

2015-03-25 Thread bearophile via Digitalmars-d
Vlad Levenfeld: Anything going on with this? Been looking forward to seeing it for awhile. It will happen. Bye, bearophile

Re: Keep Track of the Best N Nodes in a Graph Traversal Algorithm

2015-03-25 Thread bearophile via Digitalmars-d-learn
Nordlöw: Ahh, a Binary Heap perfectly matches my needs. https://en.wikipedia.org/wiki/Binary_heap http://dlang.org/phobos/std_container_binaryheap.html But isn't topNCopy using a heap? Bye, bearophile

Re: dfmt options

2015-03-23 Thread bearophile via Digitalmars-d
Jacob Carlborg: Although I would like that the D syntax allowed to drop the curly braces, like with if-satements. That would result in much nicer one-liner functions. See: https://issues.dlang.org/show_bug.cgi?id=7176 Bye, bearophile

Re: A few notes on choosing between Go and D for a quick project

2015-03-19 Thread bearophile via Digitalmars-d
Andrei Alexandrescu: You may want to answer there, not here. I've also posted a response. There is this, with an attach: https://issues.dlang.org/show_bug.cgi?id=11810 Bye, bearophile

Re: Do strings with enum allocate at usage point?

2015-03-18 Thread bearophile via Digitalmars-d-learn
岩倉 澪: However, if enum implies allocation at the usage point for strings, There are two ways to see if something allocates: there is a compiler switch, and an annotation: void foo() @nogc { // Your code here } If the compiler doesn't have a bug it will complain if you put something

Re: A few notes on choosing between Go and D for a quick project

2015-03-18 Thread bearophile via Digitalmars-d
Elazar Leibovich: I personally, would have no idea what this piece of code is doing upon first sight. I'll have to look at the documentation of at least two functions to understand that, and I'll have to think carefully about what and who would throw in case of an error. Something like

Re: A few notes on choosing between Go and D for a quick project

2015-03-18 Thread bearophile via Digitalmars-d
CraigDillabaugh: You said that Unfortunately this thinking is going out of style for good reasons. I am confused (sorry, I am at work, and didn't have time to watch the 1+ hour video you linked to - I said unfortunately because it's another reason for us to refactor and change our coding

Re: Replace core language HexStrings with library entity

2015-03-17 Thread bearophile via Digitalmars-d
Baz: https://github.com/D-Programming-Language/phobos/pull/3058 I suggest to replace litteral with literal, as in computer science: http://en.wikipedia.org/wiki/Literal_%28computer_programming%29 Bye, bearophile

Re: The next iteration of scope

2015-03-16 Thread bearophile via Digitalmars-d
Marc Schütz: Here's the new version of my scope proposal: http://wiki.dlang.org/User:Schuetzm/scope2 Let's see what Andrei and Walter think about this all :-) Bye, bearophile

Re: How to generate a random string ...

2015-03-16 Thread bearophile via Digitalmars-d-learn
Robert burner Schadek: ... from all Unicode characters in an idiomatic D way? Perhaps by rejection? I mean, generating a uint, test if it's a character and repeat until the result is true. Bye, bearophile

Re: Replace core language HexStrings with library entity

2015-03-16 Thread bearophile via Digitalmars-d
Andrei Alexandrescu: That opens the question whether we want only ubyte[] for hex bytes or all integral types. I suggest to implement only ubyte[] first. And wait for enhancement requests. Bye, bearophile

Re: A few notes on choosing between Go and D for a quick project

2015-03-16 Thread bearophile via Digitalmars-d
ninja: 2. Please stop changing the (core) language all the time. There are like 3 new proposals every week in the forums and at least 2 of those are seriously considered. Please, just stop. D is not yet finished. Ownership of memory in D is a work-in-progress. Tuples are a hole in a language

Template constraints

2015-03-15 Thread bearophile via Digitalmars-d
Observe: https://github.com/D-Programming-Language/phobos/pull/3054 Is this change the partial proof of another failure of a part of D language design? What's the point of template constraints? Aren't C++ Concepts better? Or to rephrase that in a less trollish way, can D be enhanced to add

Re: A few notes on choosing between Go and D for a quick project

2015-03-15 Thread bearophile via Digitalmars-d
Walter Bright: I'd also prefer to get rid of /+ +/ comments, I thought they'd be more useful than they are. I prefer to get rid of /* */ instead :-) Because /++/ can do things /**/ can't. Bye, bearophile

Re: Replace core language HexStrings with library entity

2015-03-15 Thread bearophile via Digitalmars-d
Marc Schütz: Can we make it so it returns a ubyte[]? There is an enhancement request on this (for the built in hex strings). Bye, bearophile

Re: get from tuple by type

2015-03-15 Thread bearophile via Digitalmars-d-learn
Charles Cooper: Yes, I could say external_api1_react_to_event(event_t[1], event_t[0]) .. but that is barbaric. It's a productivity sink because I have to go back to the original definition, align the arguments, and then context switch back to whatever I was working on before. If you are

Re: Replace core language HexStrings with library entity

2015-03-15 Thread bearophile via Digitalmars-d
Andrei Alexandrescu: hexString and hexBytes. -- Andrei Can you show me one or two different use cases of hexString? Bye, bearophile

Re: Replace core language HexStrings with library entity

2015-03-15 Thread bearophile via Digitalmars-d
Walter Bright: Unfortunately, it needs to be a dropin replacement for x..., which returns a string/wstring/dstring. This is bad. 99% of the times you don't want a string/wstring/dstring out of a hex string: https://issues.dlang.org/show_bug.cgi?id=10454

Re: Dlang seems like java now,but why not let d more like C# Style?

2015-03-14 Thread bearophile via Digitalmars-d-learn
dnewer: but,C# cant compiled to native code. Soon you will be able to compile C# natively. Bye, bearophile

Re: A few notes on choosing between Go and D for a quick project

2015-03-14 Thread bearophile via Digitalmars-d
Russel Winder: (*) IPython grew out of Python and become the de facto system, but was a mess structurally. IPython is splitting into IPython the original thing and Jupyter all the UI related stuff Jupyter looks like a nice idea and a nice project. I'd like to understand how Jupyter compared

Re: A few notes on choosing between Go and D for a quick project

2015-03-14 Thread bearophile via Digitalmars-d
Paolo Invernizzi: I'm the only one so old, that for me, studying a language from a book is the normal pattern to follow for learning it? I think it's also a matter of how you usually learn. If you are a person that loves nonfinction books a lot, that reads nonfinction books a lot, then

Re: Compilation changes

2015-03-13 Thread bearophile via Digitalmars-d-learn
Ali Çehreli: That may be related to the recent changes in the build system. Right. Have you been following the following threads? (I haven't been; so, I am sure whether they apply.) I have not. [dmd-internals] DMD now requires a working D compiler to be build Proposal : aggregated

  1   2   3   4   5   6   7   8   9   10   >