Re: repack ubyte[] to use only 7 bits

2014-12-06 Thread Charles Hixson via Digitalmars-d-learn
Your comments would be reasonable if this were destined for a library, but I haven't even finished checking it (and probably won't since I've switched to a simple zero elimination scheme). But this is a bit specialized for a library...a library should probably deal with arbitrary ints from 8 t

Re: @property usage

2014-12-06 Thread ketmar via Digitalmars-d-learn
On Sat, 06 Dec 2014 15:23:10 -0800 Jonathan M Davis via Digitalmars-d-learn wrote: > On Thursday, December 04, 2014 10:21:10 uri via Digitalmars-d-learn wrote: > > Hi All, > > > > Do you guys use @property much, or is it largely ignored/avoided? > > @property is used rather freuently - e.g. some

Re: Check type is a struct at compile time?

2014-12-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, December 05, 2014 20:38:30 Gary Willoughby via Digitalmars-d-learn wrote: > How can i check that a type is a struct at compile time? I know i > can test for a class like this: > > static if(is(T == class)) > { > ... > } > > But how to do the same thing for a struct? static if(is(T

Re: @property usage

2014-12-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, December 04, 2014 10:21:10 uri via Digitalmars-d-learn wrote: > Hi All, > > Do you guys use @property much, or is it largely ignored/avoided? @property is used rather freuently - e.g. some of the functions in the range API are required to be properties. Typically, @property is used wh

Re: Accented Characters and Counting Syllables

2014-12-06 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Dec 06, 2014 at 10:37:17PM +, "Nordlöw" via Digitalmars-d-learn wrote: > Given the fact that > > static assert("é".length == 2); > > I was surprised that > > static assert("é".byCodeUnit.length == 2); > static assert("é".byCodePoint.length == 2); > > Isn't there a way t

Re: repack ubyte[] to use only 7 bits

2014-12-06 Thread bearophile via Digitalmars-d-learn
Charles Hixson: byte[]x8to7 (ubyte[] bin) Better to add some annotations, like pure, @safe, nothrow, if you can, and to annotate the bin with an "in". intfByte, fBit; It's probably better to define them as size_t. switch (fBit) I think D doesn't yet allow this

Re: Adding days to std.datetime.Date

2014-12-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 02, 2014 14:21:35 Steven Schveighoffer via Digitalmars-d-learn wrote: > On 12/2/14 2:14 PM, Steven Schveighoffer wrote: > > > Not an oversight. > > > > Date.add and Date.roll are for adding units that are variable. > > > > For example, how many days are in a month? Answer: dep

Accented Characters and Counting Syllables

2014-12-06 Thread Nordlöw
Given the fact that static assert("é".length == 2); I was surprised that static assert("é".byCodeUnit.length == 2); static assert("é".byCodePoint.length == 2); Isn't there a way to iterate over accented characters (in my case UTF-8) in D? Or is this an inherent problem in Unicode?

Re: Adding days to std.datetime.Date

2014-12-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 02, 2014 14:14:58 Steven Schveighoffer via Digitalmars-d-learn wrote: > On 12/2/14 2:00 PM, H. S. Teoh via Digitalmars-d-learn wrote: > > On Tue, Dec 02, 2014 at 06:49:54PM +, via Digitalmars-d-learn wrote: > >>> But still, why this method > >>> http://dlang.org/phobos/std

repack ubyte[] to use only 7 bits

2014-12-06 Thread Charles Hixson via Digitalmars-d-learn
Is there a standard way to do this? The code below is untested, as I haven't yet written the x7to8 routine, and came up with a better way to do what this was to accomplish, but it feels as if this should be somewhere in the standard library, if I could only find it. /** Repack the data from a

Re: Delegate returning itself

2014-12-06 Thread Adam D. Ruppe via Digitalmars-d-learn
The problem is the recursive *alias* rather than the delegate. Just don't use the alias name inside itself so like alias MyDelegate = void delegate() delegate(); will work. The first void delegate() is the return value of the MyDelegate type.

Delegate returning itself

2014-12-06 Thread Jonathan Marler via Digitalmars-d-learn
Is there a way to create a delegate that returns itself? alias MyDelegate delegate() MyDelegate; // OR alias MyDelegate = MyDelegate delegate(); When I compile this I get: Error: alias MyDelegate recursive alias declaration The error makes sense but I still feel like there should be a way to

Re: Sorted Array Wrapper Range

2014-12-06 Thread Nordlöw
On Saturday, 6 December 2014 at 14:14:18 UTC, Tobias Pankrath wrote: Because a RandomAccessRange has no means to grow in general. Compare your proposed wrapper to http://dlang.org/phobos/std_container.html#.BinaryHeap So what should the basic operations in a SortedRange wrapper template be? A

Re: Sorted Array Wrapper Range

2014-12-06 Thread Tobias Pankrath via Digitalmars-d-learn
On Saturday, 6 December 2014 at 14:10:21 UTC, Nordlöw wrote: On Thursday, 4 December 2014 at 07:58:25 UTC, Tobias Pankrath wrote: I see two typical variants: - Direct: Always sorts on write() and modify() - Lazy: Sorts lazily on read() read() of course uses binarySearch You won't be able to

Re: Sorted Array Wrapper Range

2014-12-06 Thread Nordlöw
On Thursday, 4 December 2014 at 07:58:25 UTC, Tobias Pankrath wrote: I see two typical variants: - Direct: Always sorts on write() and modify() - Lazy: Sorts lazily on read() read() of course uses binarySearch You won't be able to grow that range, would you? Why, because of slice invalidati