Adding UDA at compile time

2015-08-26 Thread Andrea Fontana via Digitalmars-d-learn
I wonder if there's a way to add UDA to functions at compile-time (so I can read later from other parts of application). Andrea

Re: Adding UDA at compile time

2015-08-26 Thread Andrea Fontana via Digitalmars-d-learn
On Wednesday, 26 August 2015 at 14:01:00 UTC, Alex Parrill wrote: On Wednesday, 26 August 2015 at 08:19:04 UTC, Andrea Fontana wrote: I wonder if there's a way to add UDA to functions at compile-time (so I can read later from other parts of application). Andrea What do you mean? UDAs are

Re: Find on sorted range slower?

2015-08-07 Thread Andrea Fontana via Digitalmars-d-learn
On Friday, 7 August 2015 at 08:18:04 UTC, Nordlöw wrote: On Friday, 7 August 2015 at 05:21:32 UTC, Tofu Ninja wrote: HAHAH wow, this is hilarious, I just checked, nothing in std.algo takes advantage of sorted ranges, sort doesn't even take advantage of it! You pass a sorted range into sort and

Shouldn't __FUNCTION__ return function name?

2015-07-28 Thread Andrea Fontana via Digitalmars-d-learn
Check this code: http://dpaste.dzfl.pl/a76db2cde13d When __FUNCTION__ is called inside a foreach body, it appears to be: f212.myFunction.__foreachbody1 Rather than: f212.myFunction. Is it correct? How can I get the function name?

Re: Shouldn't __FUNCTION__ return function name?

2015-07-28 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 28 July 2015 at 15:13:28 UTC, Steven Schveighoffer wrote: How can I get the function name? Be outside foreach. The way foreach works in many cases (including foreach over an associative array), is that the compiler constructs an internal function delegate, then passes it to a

std.net.curl and PATCH

2015-07-22 Thread Andrea Fontana via Digitalmars-d-learn
It seems that PATCH http method is missing from std.net.curl http methods. No way to use it?

Re: OPTLINK checkpoint(256)

2015-07-20 Thread Andrea Fontana via Digitalmars-d-learn
On Monday, 20 July 2015 at 13:16:43 UTC, Lemonfiend wrote: I was still using 2.066.1. When I try to build using 2.067.0 or 2.067.1 I get: Linking... checkpoint(256) --- errorlevel 1 with an Unexpected OPTLINK Termination popup which lists a bunch of registers. I'm not sure how to proceed..

Re: how to manage the list of immutable objects

2015-07-14 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 14 July 2015 at 10:09:56 UTC, aki wrote: I like to create immutable object which is identified by name as it's key. And also need get() to look up named object which is already created. class Foo { static immutable(Foo)[string] map; string name; // and other

Re: Fixed Length Array Syntax in extern(C) Function Signatures

2015-07-10 Thread Andrea Fontana via Digitalmars-d-learn
On Friday, 10 July 2015 at 08:42:06 UTC, Per Nordlöw wrote: On Friday, 10 July 2015 at 03:18:23 UTC, Mike Parker wrote: [1]http://dlang.org/interfaceToC.html Is there any tool out there that automatically creates D wrappers from C headers`? https://github.com/jacob-carlborg/dstep ?

Re: Wrapping a C-style Array (Pointer + Length) in a Range Interface

2015-07-09 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 7 July 2015 at 12:26:33 UTC, Per Nordlöw wrote: I'm currently developing a high-level wrapper for FFMPEG at https://github.com/nordlow/justd/blob/master/tests/t_ffmpeg.d My question now becomes how to most easily wrap the iteration over streams at

Re: Implicit conversion from null in custom type

2015-05-28 Thread Andrea Fontana via Digitalmars-d-learn
What's the problem with ctor taking typeof(null)? I've just used it, maybe I missed something? On Thursday, 28 May 2015 at 11:19:39 UTC, Vladimir Panteleev wrote: I'm trying to write a type which (to some extent) emulates built-in AAs. One thing I'm having trouble with is null function

Re: Implicit conversion from null in custom type

2015-05-28 Thread Andrea Fontana via Digitalmars-d-learn
void fun(typeof(null)) { } ? On Thursday, 28 May 2015 at 13:06:27 UTC, Vladimir Panteleev wrote: On Thursday, 28 May 2015 at 12:37:52 UTC, Andrea Fontana wrote: What's the problem with ctor taking typeof(null)? I've just used it, maybe I missed something? It doesn't work: //

Null argument and function resolution

2015-05-27 Thread Andrea Fontana via Digitalmars-d-learn
Check this example: http://dpaste.dzfl.pl/53f85bae4382 Calling with null, both c-tor match. Is there a way to solve this? Something like: this(in ubyte* data) if( ??? ) { } Andrea

Re: Null argument and function resolution

2015-05-27 Thread Andrea Fontana via Digitalmars-d-learn
The first answer is the one I was looking for. Very useful. You should add to next this week in d tips. On Wednesday, 27 May 2015 at 14:09:48 UTC, Adam D. Ruppe wrote: Two options: 1) add an overload that takes typeof(null) this(typeof(null)) { /* handles the null literal specially */ } 2)

Re: Internal Compiler Error Help

2015-05-21 Thread Andrea Fontana via Digitalmars-d-learn
https://github.com/CyberShadow/DustMite/wiki On Thursday, 21 May 2015 at 08:28:30 UTC, Saurabh Das wrote: Hello, We have been working on a genetic programming project, and occasionally the compiler fails and gives an internal error. I've captured and reduced one of these down to a single

Re: Merging one Array with Another

2015-05-08 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 7 May 2015 at 21:53:24 UTC, Per Nordlöw wrote: On Thursday, 7 May 2015 at 13:38:23 UTC, Andrea Fontana wrote: Because it is a more generic operation and you can work on a lazy range. Anyway, to sort and to do uniq it isn't the fastest way. Or maybe I just didn't understand what

Re: Merging one Array with Another

2015-05-08 Thread Andrea Fontana via Digitalmars-d-learn
On Friday, 8 May 2015 at 09:23:42 UTC, Per Nordlöw wrote: On Friday, 8 May 2015 at 08:27:19 UTC, Andrea Fontana wrote: Name could be misleading. This is a sortedrange: [4,3,2,1,0]. In your case minElement is 4, maxElement is 0 :) On ranges with more complex elements sort order can be even less

Re: Merging one Array with Another

2015-05-07 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 7 May 2015 at 06:53:39 UTC, Per Nordlöw wrote: On Wednesday, 6 May 2015 at 16:05:15 UTC, Andrea Fontana wrote: Maybe a way like this could be useful: http://dpaste.dzfl.pl/7b4b37b490a7 If r is a SortedRange this is very unneccesary wasteful because of the use AA. In that case

Re: Merging one Array with Another

2015-05-07 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 7 May 2015 at 09:21:58 UTC, Per Nordlöw wrote: On Thursday, 7 May 2015 at 08:03:41 UTC, Andrea Fontana wrote: It's not that difficult to implement. You just need to implement a merge() range that returns the min of all ranges' front(). Then you can define distinct() for

Re: vibed: how to use pure HTML instead of template engine?

2015-05-06 Thread Andrea Fontana via Digitalmars-d-learn
On Wednesday, 6 May 2015 at 14:28:26 UTC, Adam D. Ruppe wrote: On Wednesday, 6 May 2015 at 14:23:27 UTC, Chris wrote: Especially this: http://vibed.org/templates/diet#embedded-code I think that's a misfeature... if I used vibe.d, I'd want to avoid the diet too. I agree

Re: Merging one Array with Another

2015-05-06 Thread Andrea Fontana via Digitalmars-d-learn
On Friday, 1 May 2015 at 19:08:51 UTC, Per Nordlöw wrote: What's the fastest Phobos-way of doing either x ~= y; // append x = x.uniq; // remove duplicates or x = (x ~ y).uniq; // append and remove duplicates in one go provided that T[] x, y; ? Maybe a way like this could

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

2015-04-28 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 28 April 2015 at 13:59:48 UTC, Ivan Kazmenko wrote: On Tuesday, 28 April 2015 at 10:46:54 UTC, Gary Willoughby wrote: After reading the following thread: http://forum.dlang.org/thread/nczgumcdfystcjqyb...@forum.dlang.org I wondered if it was possible to write a classic fizzbuzz[1]

About @ and UDA

2015-04-15 Thread Andrea Fontana via Digitalmars-d-learn
My 2 cents. If I remember correctly, @ prefix in @safe, @trusted, @system, etc was added just to avoid keywords pollution, right? Now UDA uses the same prefix: if some new keywords/properties/attributes will be added to D, the same problem will come back again... Is it a crazy idea to

Re: Strange behavior std.range.takeNone

2015-04-07 Thread Andrea Fontana via Digitalmars-d-learn
Yes it is. takeNone() take a char from a string. So you are going to append a char (with code 5) on the next line. If you replace that line with: s ~= 65; it will print A. (65 is ascii code for letter 'A') On Tuesday, 7 April 2015 at 02:24:00 UTC, Dennis Ritchie wrote: Hi, Is it OK? -

Re: Reflections on isPalindrome

2014-10-28 Thread Andrea Fontana via Digitalmars-d-learn
On Monday, 27 October 2014 at 22:53:57 UTC, Nordlöw wrote: Why bidirectional range only? popBack() only for I mean: you should write a different version for non-bidirectional ranges too :)

Re: Reflections on isPalindrome

2014-10-27 Thread Andrea Fontana via Digitalmars-d-learn
On Monday, 27 October 2014 at 16:59:19 UTC, Nordlöw wrote: On Monday, 27 October 2014 at 12:10:59 UTC, Marc Schütz wrote: You could add an early `return false;` if the range has length and it is less than minLength. See update :) Thanks! And you can return true if length = 1 Why

Re: SImple C++ code to D

2014-07-14 Thread Andrea Fontana via Digitalmars-d-learn
Is there any counter-indication with this: immutable ubyte[5] stub = xb8 01 4c cd 21.representation; ? Is it a compile time value? On Monday, 14 July 2014 at 12:18:20 UTC, bearophile wrote: Alexandre: Look at line 114 of my code: http://dpaste.com/3B5WYGV The indentations are messed up.

Re: how can I ensure that a template instantiation is unique?

2014-06-19 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 19 June 2014 at 05:48:24 UTC, Vlad Levenfeld wrote: I'm instantiating a couple of template structs that conflict with each other. I'd like them to be unique types, automatically. So I tried this: template Foo (string unique_id = __FILE__~__LINE__.to!string) {...} but it didn't

Re: how can I ensure that a template instantiation is unique?

2014-06-19 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 19 June 2014 at 07:26:12 UTC, Andrea Fontana wrote: On Thursday, 19 June 2014 at 05:48:24 UTC, Vlad Levenfeld wrote: I'm instantiating a couple of template structs that conflict with each other. I'd like them to be unique types, automatically. So I tried this: template Foo

<    1   2   3