Re: random access-range without lower-power range kinds?

2010-12-14 Thread Lars T. Kyllingstad
On Tue, 14 Dec 2010 09:09:33 +0100, spir wrote: Hello, It seems impossible to define a random-access range (opIndex + length) alone. In fact, I cannot have it used by the language. Am I missing something? Random-access looks enough to provide fonctionality for both input and bidirectional

Re: string comparison

2010-12-20 Thread Lars T. Kyllingstad
On Sun, 19 Dec 2010 07:01:30 +, doubleagent wrote: Andrei's quick dictionary illustration [in his book, 'The D Programming Language'] doesn't seem to work. Code attached. That's strange. I ran the example you posted using DMD 2.050 myself, and it works for me. Are you 100% sure that

Re: string comparison

2010-12-20 Thread Lars T. Kyllingstad
On Mon, 20 Dec 2010 18:44:12 +, doubleagent wrote: Are you 100% sure that you are running this version I have to be. There are no other versions of phobos on this box and 'which dmd' points to the correct binary. dictionary[word.idup] = newId; That fixes it. The 'word' array

Re: Why does the example on page 8 of TDPL work without importing std.algorithm for splitter?

2011-01-04 Thread Lars T. Kyllingstad
On Mon, 03 Jan 2011 17:18:34 -0600, Ellery Newcomer wrote: If you're importing some other phobos module, I would guess an instance of this bug: http://d.puremagic.com/issues/show_bug.cgi?id=314 On 01/03/2011 10:56 AM, Bryce Watkins wrote: However when I use splitter in my code it works

Re: Memory mapped IO

2011-01-10 Thread Lars T. Kyllingstad
On Sun, 09 Jan 2011 22:44:44 -0800, Dan Olson wrote: I'm exploring D for embedded work as a nice alternative to C/C++ for the 32-bitters and am finding it has a nice set of features. But, what is the best way handle memory mapped IO? I don't see volatile like in C. Is writing asm {} the

Re: auto declarations

2011-01-10 Thread Lars T. Kyllingstad
On Fri, 07 Jan 2011 16:30:24 -0800, Jonathan M Davis wrote: On Friday, January 07, 2011 13:32:42 Ellery Newcomer wrote: auto a = 1, b = null; int a = 1, *b = null; [...] [...] However, I'm vere suprised that the first one succeeds. I think that it should be reported as a bug. All

Re: Memory mapped IO

2011-01-10 Thread Lars T. Kyllingstad
On Mon, 10 Jan 2011 08:38:15 -0800, Dan Olson wrote: Lars T. Kyllingstad pub...@kyllingen.nospamnet writes: On Sun, 09 Jan 2011 22:44:44 -0800, Dan Olson wrote: I'm exploring D for embedded work as a nice alternative to C/C++ for the 32-bitters and am finding it has a nice set of features

Re: How to use std.bind?

2011-01-18 Thread Lars T. Kyllingstad
On Mon, 17 Jan 2011 17:03:15 +, Sean Eskapp wrote: I used to use boost::bind all the time, but std.bind has me stumped, as I keep getting static asserts with a cryptic argument has no parameters message. At this point, the code is just: class Foo { void bar(int i) { writeln(i);

Re: std.container.Array/RefCounted(T) leaking memory?

2011-01-18 Thread Lars T. Kyllingstad
On Tue, 18 Jan 2011 01:16:51 +, %u wrote: I find it very hard to believe that struct dtors are never called. Sorry, that part was my bad -- last time I checked, they didn't get called, but maybe my example was too complicated, since they did get called for a *simple* example.

Re: non-constant error for module AAs

2011-01-25 Thread Lars T. Kyllingstad
On Mon, 24 Jan 2011 10:45:03 -0500, Andrej Mitrovic wrote: Is this a bug? import std.stdio; string[string] values = [abc:abc, def:def]; void main() { string[string] values2 = [abc:abc, def:def]; } test.d(3): Error: non-constant expression [abc:abc,def:def] What's

Re: std.format example not working

2011-01-29 Thread Lars T. Kyllingstad
On Fri, 28 Jan 2011 23:30:06 -0500, Akakima wrote: Firt, i would like to know if you are interested in receiving comments an bug reports for DMD V1. D1 bugs are still fixed, so bug reports are welcome. http://d.puremagic.com/issues/ D1 has been declared stable, though, so there is usually

Re: __gshared static versus static __gshared

2011-01-29 Thread Lars T. Kyllingstad
On Sat, 29 Jan 2011 08:47:21 +, %u wrote: Is this a bug? __gshared static i; makes i be thread-local, while static __gshared i; makes it be shared. If that's the case, then it is definitely a bug. The order of attributes shouldn't matter. -Lars

Re: higher-order funcs for ranges (with usual interface)

2011-02-02 Thread Lars T. Kyllingstad
On Wed, 02 Feb 2011 13:26:39 +0100, spir wrote: Hello, This bit of code for arrays: Out[] map (In,Out) (In[] input, Out delegate (In) f) { Out[] output = new Out[](input.length); foreach (i,item ; input) output [i] = f(item); return output; } unittest { char

Re: higher-order funcs for ranges (with usual interface)

2011-02-02 Thread Lars T. Kyllingstad
On Wed, 02 Feb 2011 13:18:07 +, Lars T. Kyllingstad wrote: [...] struct Map(Range, In, Out) if (isInputRange!Range is(ElementType!Range : In) { Range input; Out delegate(In) f; @property bool empty() { return input.empty; } // Inefficient

Re: default '==' on structs

2011-02-02 Thread Lars T. Kyllingstad
On Wed, 02 Feb 2011 15:55:53 +0100, spir wrote: Hello, What are the default semantics for '==' on structs? I ask this because I was forced to write opEquals on a struct to get expected behaviour. This struct is basically: struct Lexeme { string tag; string slice;

Re: higher-order funcs for ranges (with usual interface)

2011-02-02 Thread Lars T. Kyllingstad
On Wed, 02 Feb 2011 18:38:02 +0100, spir wrote: On 02/02/2011 02:18 PM, Lars T. Kyllingstad wrote: On Wed, 02 Feb 2011 13:26:39 +0100, spir wrote: Hello, This bit of code for arrays: Out[] map (In,Out) (In[] input, Out delegate (In) f) { Out[] output = new Out[](input.length

Re: default '==' on structs

2011-02-03 Thread Lars T. Kyllingstad
On Wed, 02 Feb 2011 17:35:50 +0100, spir wrote: On 02/02/2011 04:20 PM, Lars T. Kyllingstad wrote: On Wed, 02 Feb 2011 15:55:53 +0100, spir wrote: Hello, What are the default semantics for '==' on structs? I ask this because I was forced to write opEquals on a struct to get expected

Re: higher-order funcs for ranges (with usual interface)

2011-02-03 Thread Lars T. Kyllingstad
On Thu, 03 Feb 2011 13:05:00 +0100, spir wrote: On 02/03/2011 08:41 AM, Lars T. Kyllingstad wrote: On Wed, 02 Feb 2011 18:38:02 +0100, spir wrote: I guess the only solution would be for the compiler to support a kind of reange type syntax? I'm not sure I understand what you mean here

Re: higher-order funcs for ranges (with usual interface)

2011-02-03 Thread Lars T. Kyllingstad
On Thu, 03 Feb 2011 13:53:44 +0100, spir wrote: On 02/03/2011 01:17 PM, Lars T. Kyllingstad wrote: Why the reluctance to use template constraints? They're so flexible! :) I cannot stand the is() idiom/syntax ;-) Dunno why. Would happily get rid of it in favor of type-classes (built eg

Re: higher-order funcs for ranges (with usual interface)

2011-02-07 Thread Lars T. Kyllingstad
On Thu, 03 Feb 2011 19:11:04 +0100, spir wrote: On 02/03/2011 02:25 PM, Lars T. Kyllingstad wrote: On Thu, 03 Feb 2011 13:53:44 +0100, spir wrote: On 02/03/2011 01:17 PM, Lars T. Kyllingstad wrote: Why the reluctance to use template constraints? They're so flexible! :) I cannot stand

Re: MD5 hash on a file and rawRead

2011-02-10 Thread Lars T. Kyllingstad
On Wed, 09 Feb 2011 23:01:47 -0500, Andrej Mitrovic wrote: I'm trying to use the std.md5.sum method. It takes as an argument a digest to output the hash to, and the second argument is plain data. So I'm trying to read an entire file at once. I thought about using rawRead, but I get a

Re: How to web programming with D2?

2011-02-10 Thread Lars T. Kyllingstad
On Thu, 10 Feb 2011 04:29:21 -0500, canalpay wrote: I am trying to write the web framework(but not to write, to gain experience.). Maybe the framework can has got a MVC desing pattern. But first, the D2 is not has got for the web library and I am decided write to library for web. I am

Re: Dynamic and Static Casting

2011-02-10 Thread Lars T. Kyllingstad
On Thu, 10 Feb 2011 11:54:02 +, Lars T. Kyllingstad wrote: On Thu, 10 Feb 2011 16:44:12 +0530, d coder wrote: Greetings All I have learnt that D has only one casting operator and that is 'cast'. The same operator assumes different functionality depending on the context in which it he

Re: Git library for checkouts?

2011-02-15 Thread Lars T. Kyllingstad
On Tue, 15 Feb 2011 21:32:06 +0100, Jacob Carlborg wrote: Maybe a little off topic but does anyone know about a git library, I'll only need to do checkouts? Here is a C library, written by the folks behind GitHub: https://github.com/schacon/libgit -Lars

Re: Checking if something is a template specialization?

2011-02-18 Thread Lars T. Kyllingstad
On Fri, 18 Feb 2011 02:02:51 +, Sean Eskapp wrote: If I have class Bar(T) { } void foo(Y)() { ... } Is there a way to check inside foo() that Y is in some way an instantiation of Bar? Is there a way to find WHICH instantiation it is? void foo(Y)() { static if (is(Y Z

Re: datetime fails with undefined reference

2011-02-18 Thread Lars T. Kyllingstad
On Fri, 18 Feb 2011 16:38:19 +, Kai Meyer wrote: I can't seem to use std.datetime at all. I get undefined reference on whether I use a StopWatch, or if I just try to compile the unittest. All I have to do is declare a StopWatch: import std.stdio; import std.datetime; void main() {

Re: Finding out if T is a specialization of another template

2011-02-18 Thread Lars T. Kyllingstad
On Fri, 18 Feb 2011 17:16:02 +, Sean Eskapp wrote: I was given this code, to check if Y is a specialization of Bar. How does it work? class Bar(T) { } void foo(Y)() { static if (is(Y Z == Bar!Z)) { // Here, Z is now an alias to whichever type Bar is //

Re: datetime fails with undefined reference

2011-02-18 Thread Lars T. Kyllingstad
On Fri, 18 Feb 2011 10:23:41 -0800, Jonathan M Davis wrote: On Friday, February 18, 2011 10:12:09 Kai Meyer wrote: Great news! Worked like a champ. Is there documentation somewhere that I missed? I would love to be able to answer these questions on my own. I've been stumped on this one for a

Re: Finding out if T is a specialization of another template

2011-02-18 Thread Lars T. Kyllingstad
On Fri, 18 Feb 2011 20:37:38 +, Sean Eskapp wrote: == Quote from Lars T. Kyllingstad (public@kyllingen.NOSPAMnet)'s article On Fri, 18 Feb 2011 17:16:02 +, Sean Eskapp wrote: I was given this code, to check if Y is a specialization of Bar. How does it work? class Bar(T

Re: Is std.array.replace supposed to work with char[]?

2011-02-21 Thread Lars T. Kyllingstad
On Sun, 20 Feb 2011 15:23:29 -0500, Steven Schveighoffer wrote: On Sun, 20 Feb 2011 14:51:10 -0500, bearophile bearophileh...@lycos.com wrote: Jacob Carlborg: Every time I try to use D2 it's just a PITA to use. I've used D1 and Tango for several years and had no problem with that. I

Re: rdmd problems (OS X Leopard, DMD 2.052)

2011-02-21 Thread Lars T. Kyllingstad
On Mon, 21 Feb 2011 12:18:54 +0100, Magnus Lie Hetland wrote: On 2011-02-20 19:22:20 +0100, Magnus Lie Hetland said: On 2011-02-19 22:25:31 +0100, Nick Sabalausky said: [snip] Unfortunately, rdmd doesn't seem to have gotten much attention lately. I've had a few patches for it sitting in

What is -nofloat good for?

2011-02-24 Thread Lars T. Kyllingstad
The dmd help text says the following about the -nofloat switch: -nofloat do not emit reference to floating point What does this mean? What is -nofloat good for? -Lars

Re: %x and floats

2011-02-25 Thread Lars T. Kyllingstad
On Thu, 24 Feb 2011 13:27:39 -0500, Trass3r wrote: Why doesn't this work: import std.stdio; void main() { float a,b=0; writefln(%x %x, a, b); } std.format.FormatError: std.format floating That is because %x is for formatting integers. If you want a hex representation of

Re: Version very simple?

2011-02-27 Thread Lars T. Kyllingstad
On Sun, 27 Feb 2011 15:52:01 +0100, simendsjo wrote: I'm having some problems grokking version. How would I translate this simple C macro? #if !defined(IDENT) || !defined(IDENT2) I've tried the following: version(!IDENT) identifier or integer expected, not ! !version(IDENT)

Re: Two questions about %a

2011-03-02 Thread Lars T. Kyllingstad
On Wed, 02 Mar 2011 13:35:11 +0100, Magnus Lie Hetland wrote: First question: I just noticed that writefln(%a, 1.2) writes 0x1.3p+0, while writeln(format(%a, 1.2)) (that is, with std.string.format) writes 0x9.8p-3 ... wouldn't it be nice to be consistent here? (The

Re: in/out with -release

2011-03-05 Thread Lars T. Kyllingstad
On Sat, 05 Mar 2011 18:12:30 +, Lars T. Kyllingstad wrote: On Sat, 05 Mar 2011 10:15:48 -0700, user wrote: On 03/04/2011 09:22 PM, Jonathan M Davis wrote: On Friday 04 March 2011 20:14:32 Kai Meyer wrote: I have an 'enforce' function call in an 'in' block for a function. When I compile

Re: Reading a line from stdin

2011-03-16 Thread Lars T. Kyllingstad
On Wed, 16 Mar 2011 11:20:43 +0100, spir wrote: On 03/16/2011 06:41 AM, Jesse Phillips wrote: Ali Çehreli Wrote: Right? Is there a better way that I am missing? Thank you, Ali No better way, the stated reason IIRC is that it is easier to remove the new line then to append it back on.

Re: What is put() useful for with regards to dynamic arrays?

2011-05-02 Thread Lars T. Kyllingstad
On Sat, 30 Apr 2011 00:09:09 -0400, Andrej Mitrovic wrote: import std.range; void main() { int[] a = [1, 2, 3]; a.put(6); assert(a == [2, 3]); a.put([1, 2]); assert(a.length == 0); } Seems kind of odd.. put is implemented as an append method for some

Re: how to migrate to std.datetime

2011-05-09 Thread Lars T. Kyllingstad
On Mon, 09 May 2011 09:49:04 +0100, Russel Winder wrote: On Sun, 2011-05-08 at 23:52 -0700, Jonathan M Davis wrote: [ . . . ] I could look at writing an article on moving from std.date to std.datetime, I suppose. We already have an article contest going, and it would make sense to put such an

Re: Advice on threading/fibers/?

2011-06-16 Thread Lars T. Kyllingstad
On Wed, 15 Jun 2011 23:57:25 +, Justin Whear wrote: Consider the following: You have 10 million data points and you need to apply a multipass algorithm to them. Each pass is like a cellular automata: it can read from the previous pass but it doesn't know the current values. This makes

Re: Pure not acting pure.

2011-06-16 Thread Lars T. Kyllingstad
On Thu, 16 Jun 2011 06:52:45 -0400, Michel Fortin wrote: On 2011-06-15 23:29:46 -0400, Charles McAnany mcana...@rose-hulman.edu said: Ah, so does the compiler figure out which ones are strongly and weakly pure and then optimize as appropriate? Is there a way to indicate that a function is

Re: Pure not acting pure.

2011-06-16 Thread Lars T. Kyllingstad
On Thu, 16 Jun 2011 17:38:27 +, Charles McAnany wrote: Ok, I think I get it. That cleared it up. =). So, if you have a functioned labelled pure, it's your job to not pass it mutable arguments, but the compiler's job to make sure it doesn't mutate anything not in the arguments. And that's

Re: Different NaNs used

2011-06-29 Thread Lars T. Kyllingstad
On Mon, 27 Jun 2011 16:41:14 -0400, bearophile wrote: This question is related to this thread: http://d.puremagic.com/issues/show_bug.cgi?id=3632 Can you tell me why real.nan and real.init don't contain the same bit patterns? import std.math: isIdentical; void main() {

Re: Resource availability: fonts

2009-05-06 Thread Lars T. Kyllingstad
grauzone wrote: Use ubyte[] fontbytes = cast(ubyte[])import(yourfont.ttf); That is so cool. I've seen the import() expression mentioned here on the NG before. It returns a string containing the imported source file, right? Is it mentioned anywhere in the docs? I can't seem to find it.

Re: Compile-time int-to-string conversion

2009-05-06 Thread Lars T. Kyllingstad
bearophile wrote: Lars T. Kyllingstad: How can one, in D2, at compile time, convert an integer value (or any other type, for that matter) to a string? std.metastrings.ToString or std.metastrings.Format, but in D2 that Format is buggy. Bye, bearophile Thank you. ToString did the job

Cryptic DMD error

2009-05-07 Thread Lars T. Kyllingstad
Can someone with knowledge of the DMD source code please explain this error message for me? dmd: glue.c:652: virtual void FuncDeclaration::toObjFile(int): Assertion `!v-csym' failed. I had a look at the DMD source to try and make some sense of it myself, but didn't succeed. I am using the

Re: Cryptic DMD error

2009-05-08 Thread Lars T. Kyllingstad
Don wrote: Lars T. Kyllingstad wrote: Can someone with knowledge of the DMD source code please explain this error message for me? dmd: glue.c:652: virtual void FuncDeclaration::toObjFile(int): Assertion `!v-csym' failed. I had a look at the DMD source to try and make some sense

Re: Cryptic DMD error

2009-05-11 Thread Lars T. Kyllingstad
Don wrote: Lars T. Kyllingstad wrote: Don wrote: Lars T. Kyllingstad wrote: Can someone with knowledge of the DMD source code please explain this error message for me? dmd: glue.c:652: virtual void FuncDeclaration::toObjFile(int): Assertion `!v-csym' failed. I had a look at the DMD

Why use float and double instead of real?

2009-06-23 Thread Lars T. Kyllingstad
Is there ever any reason to use float or double in calculations? I mean, when does one *not* want maximum precision? Will code using float or double run faster than code using real? I understand they are needed for I/O and compatibility purposes, so I am by no means suggesting they be removed

Re: std.process: bug or my fault?

2009-07-01 Thread Lars T. Kyllingstad
novice2 wrote: I want to use Phobos std.process.execv(in string pathname, in immutable(char)[][] argv) to execute external programm with some parameter. But i found, that can't pass parameter properly - they not passed. Here very short example - caller.exe shoud call called.exe with parameters:

Re: help with c translation

2009-07-02 Thread Lars T. Kyllingstad
robby wrote: can anybody help me translate this c function to d, im having a problem with the data types. thanks. //- unsigned int BLZCC blz_pack(const void *source, void *destination, unsigned int length,

Re: help with c translation

2009-07-02 Thread Lars T. Kyllingstad
robby wrote: thanks for help, i did the conversion as you mentioned and i get various errors involving constant, lvalue, etc., just fyi, its part of code from brieflz (LZ77 variant) which ive been trying to port to D for use in my program. Perhaps you could paste the error messages here?

Re: help with c translation

2009-07-02 Thread Lars T. Kyllingstad
robby wrote: i'm using D1/Tango. sorry, im not sure to how to explain the error messages, but if you need to look a t full code, here is the link http://www.ibsensoftware.com/download.html thanks again. Several places in that code, I notice things like this: const type foo; ...

Re: help with c translation

2009-07-02 Thread Lars T. Kyllingstad
Ary Borenszweig wrote: Lars T. Kyllingstad escribió: robby wrote: i'm using D1/Tango. sorry, im not sure to how to explain the error messages, but if you need to look a t full code, here is the link http://www.ibsensoftware.com/download.html thanks again. Several places in that code, I

Re: help with c translation

2009-07-02 Thread Lars T. Kyllingstad
BCS wrote: Hello Ary, Well, it should work! const means, once a value is assigned to that variable, it never changes again. The compiler can do static analysis to verify this. And that's why it works. And that's why D should also work this way, IMHO. In D1, const is truly const, as in never

Re: D2 using std.proccess.shell

2009-07-07 Thread Lars T. Kyllingstad
Jesse Phillips wrote: I don't know if I'm misunderstanding the use of shell() or if this is a bug. Trying to run some programs with shell error with a could not close file. Sadly it I can come to any reasonable conclusion as to why. Example output from running writeln(shell(gcc)) gcc: no

Re: D2 using std.proccess.shell

2009-07-08 Thread Lars T. Kyllingstad
Jesse Phillips wrote: On Tue, 07 Jul 2009 12:04:43 +0200, Lars T. Kyllingstad wrote: Jesse Phillips wrote: I don't know if I'm misunderstanding the use of shell() or if this is a bug. Trying to run some programs with shell error with a could not close file. Sadly it I can come to any

Re: D2 using std.proccess.shell

2009-07-09 Thread Lars T. Kyllingstad
Jesse Phillips wrote: On Tue, 07 Jul 2009 12:04:43 +0200, Lars T. Kyllingstad wrote: Jesse Phillips wrote: I don't know if I'm misunderstanding the use of shell() or if this is a bug. Trying to run some programs with shell error with a could not close file. Sadly it I can come to any

Re: need help convert c code

2009-07-17 Thread Lars T. Kyllingstad
D. Reeds wrote: Robert Fraser Wrote: D. Reeds wrote: can anybody help me translate this c code into d, im using D1+tango combo. i'm new to D and got stucked on multi-dimension array part. int levenshtein_distance(char *s,char*t) //Compute levenshtein distance between s and t { //Step 1

Re: need help convert c code

2009-07-17 Thread Lars T. Kyllingstad
D. Reeds wrote: Lars T. Kyllingstad Wrote: Fun fact: There is already a Levenshtein distance algorithm in Phobos for D2: http://www.digitalmars.com/d/2.0/phobos/std_algorithm#levenshteinDistance I know you said you use D1+Tango, I just thought I should mention it. The source code

Re: void myMethod() throw()

2009-07-20 Thread Lars T. Kyllingstad
Sam Hu wrote: Does D2 has the equivalent implemenation of exception no throw out of a method: void myMethod() throw(){} Or,D2 has its own/better implementation on such feature,if yes,what is that? Thanks in advance. Regards, Sam Yes, it's called nothrow. :) nothrow void myMethod() { ... }

Re: There is not std.stdio.flush

2009-07-20 Thread Lars T. Kyllingstad
Haruki Shigemori wrote: Hi. The std.cstream.dout has a member function dout.flush. But the std.stdio has not a function flush or a similar function. Why? Don't you want to have it? Give me the std.stdio.flush! All the write functions in std.stdio (write, writeln, writef, writefln) flush

Re: There is not std.stdio.flush

2009-07-20 Thread Lars T. Kyllingstad
Lars T. Kyllingstad wrote: Haruki Shigemori wrote: Hi. The std.cstream.dout has a member function dout.flush. But the std.stdio has not a function flush or a similar function. Why? Don't you want to have it? Give me the std.stdio.flush! All the write functions in std.stdio (write, writeln

Re: There is not std.stdio.flush

2009-07-20 Thread Lars T. Kyllingstad
Ary Borenszweig wrote: Lars T. Kyllingstad wrote: Lars T. Kyllingstad wrote: Haruki Shigemori wrote: Hi. The std.cstream.dout has a member function dout.flush. But the std.stdio has not a function flush or a similar function. Why? Don't you want to have it? Give me the std.stdio.flush

Re: At compile time

2009-08-05 Thread Lars T. Kyllingstad
Don wrote: Jarrett Billingsley wrote: I don't think you can call struct methods at compile-time. Kind of lame, I know. Try making norm a free function. Can the D2 compiler modified/improved to allow this? It sure would be nice. In fact the D1 compiler should support it too. BTW a few of

A floating-point puzzle

2009-08-05 Thread Lars T. Kyllingstad
Here's a puzzle for you floating-point wizards out there. I have to translate the following snippet of FORTRAN code to D: REAL B,Q,T C -- C |*** COMPUTE MACHINE BASE ***| C -- T = 1. 10T = T + T IF (

Re: 'static' keyword for positional array initialization

2009-08-12 Thread Lars T. Kyllingstad
Ali Cehreli wrote: The 'static' keyword is required by dmd 2.031 for the second of these two definitions: int[2] static_0 = [ 1, 1 ]; static int[2] static_1 = [ 1:1 ]; Is this inconsistency by design? Should 'static' be required for both or neither? Ali I've tried with DMD 2.031,

Re: Is [ 0, 1, 2 ] an immutable array?

2009-08-12 Thread Lars T. Kyllingstad
Ali Cehreli wrote: Does the expression [ 0, 1, 2 ] form an immutable array? If so, is the assignment to a[0] undefined below? Is it trying to modify an immutable element? int[] a = [ 0, 1, 2 ]; a[0] = 42; The reason for my thinking that [ 0, 1, 2] is an array is because it has the

Re: ignored phobos request

2009-08-12 Thread Lars T. Kyllingstad
Saaa wrote: Some time ago I requested something on .D, but it was ignored. I'm interested in why this is so. It was only a small request, maybe not fitting for .D but dsourse/phobos said that was the place for such things. (Maybe it was unintelligible again?) The place (.D) was right, but I

Re: overloading

2009-08-12 Thread Lars T. Kyllingstad
Ellery Newcomer wrote: Why is function overloading not applied to nested functions? Good question. Intuitively it seems to me that they should act just like other functions. I couldn't find anything about it in the spec, but I found this (on the Functions page): Unlike module level

Re: ignored phobos request

2009-08-12 Thread Lars T. Kyllingstad
Saaa wrote: Lars T. Kyllingstad pub...@kyllingen.nospamnet wrote in message news:h5tsuu$bc...@digitalmars.com... Saaa wrote: Some time ago I requested something on .D, but it was ignored. I'm interested in why this is so. It was only a small request, maybe not fitting for .D but dsourse/phobos

Re: Partial template function specialization

2009-08-20 Thread Lars T. Kyllingstad
Peter Alexander wrote: Simen Kjaeraas Wrote: Macros are currently scheduled for D3. In the meantime, you can do just about anything with string mixins and CTFE. Cool. Is there any sort of ETA on D3? Man, we just got the ETA on D2... :) -Lars

Re: Partial template function specialization

2009-08-20 Thread Lars T. Kyllingstad
Peter Alexander wrote: Hey all, I'm considering learning D at the moment, and one thing that has bothered me in C++ is the lack of partial template function specializations. For example, you can create something like this: template class Field, class V const Field norm(const V v); and you

Re: Any way to workaround Optlink crash?

2009-09-01 Thread Lars T. Kyllingstad
Tom S wrote: Max Samukha wrote: Tom S wrote: And/or compile some modules without -g. Maybe you don't need debug symbols everywhere. And please vote for http://d.puremagic.com/issues/votes.cgi?action=show_bugbug_id=424. Something makes Walter think this bug is not critical. I think he

Re: Long has no effect in expression (0)

2009-11-02 Thread Lars T. Kyllingstad
bearophile wrote: Sam Hu Wrote: It seems the error is not located in the code you have shown: http://codepad.org/ti7SaAtA So I think you have to show more code. Try to create a reduced case that shows the same error. You won't necessarily be able to reproduce the error with codepad.org

Re: cast(int) getting an unexpected number

2009-11-04 Thread Lars T. Kyllingstad
Michal Minich wrote: Hello rmcguire, why is this not a compiler bug? because: import std.stdio; void main() { float f=0.01; writefln(%0.2f-%d,f,cast(int)(f*100f)); writefln(%0.2f-%d,f,cast(int)(.01*100f)); writefln(%0.2f-%f,f,(f*100f)); } results in: 0.01-0 0.01-1 0.01-1.00 I would say

Re: cast(int) getting an unexpected number

2009-11-04 Thread Lars T. Kyllingstad
Charles Hixson wrote: Lars T. Kyllingstad wrote: Michal Minich wrote: Hello rmcguire, why is this not a compiler bug? because: import std.stdio; void main() { float f=0.01; writefln(%0.2f-%d,f,cast(int)(f*100f)); writefln(%0.2f-%d,f,cast(int)(.01*100f)); writefln(%0.2f-%f,f,(f*100f

Re: error linking to my own custom module

2009-11-11 Thread Lars T. Kyllingstad
torhu wrote: On 11.11.2009 04:57, Sean Fennell wrote: I'm very green to D, just learning it now. I have a module that I wrote. Its pretty simple, just helper functions to get input from user as certain data types GetInt() GetString() GetChar() etc... I compiled the module using dmd -lib

Re: template type check syntax

2009-11-22 Thread Lars T. Kyllingstad
Gzp wrote: void foo(T)(ref T t) if (isPrime!(T)) { ... } void foo(T)(ref T t) if (!isPrime!(T)) { ... } What is the difference b/n void foo(T)(ref T t) if (isPrime!(T)) { ... } and void foo(T)(ref T t) static if (isPrime!(T)) { ... } as both of them seems to be a compile time check for me.

Re: why can't structs implement interfaces?

2009-11-25 Thread Lars T. Kyllingstad
Don wrote: bearophile wrote: Bill Baxter: The good thing is that since most of the machinery is there, the actual compiler changes required would mostly be just rewrites of new syntax in terms of existing functionality. I agree, this looks like something that can be added to D even after

Re: Detect runtime vs ctfe?

2009-11-29 Thread Lars T. Kyllingstad
Nick Sabalausky wrote: Is there an idiom, preferably D1, to detect whether or not the code is currently executing as a ctfe? Ie: void foo() { (static?) if( ) { // Run-time code here // that does stuff the CTFE engine chokes on } else { // CTFE

Re: Are named variadic arguments possible?

2010-01-06 Thread Lars T. Kyllingstad
downs wrote: Alex wrote: Is it possible, using templates, tuples, or some other mechanism, to implement named variadic arguments in D? For example, I'd like to be able to do something like... foo( 2, bar, age : 10, status : down); and so forth. Yes, with a small hack. typedef int

Re: Timer library?

2010-01-25 Thread Lars T. Kyllingstad
strtr wrote: Stanislav Blinov Wrote: Pelle M幩sson wrote: I'm in need for a timer library that measures the acutal time. I have tried std.c.time's clock(), but it only measures time spent inside the program, not actual time elapsed. I need at least millisecond resolution, so

Re: Module-level private not honored?

2010-02-03 Thread Lars T. Kyllingstad
Ali Çehreli wrote: Do I understand module level access rights correctly, or is there a dmd bug? Instead of coming up with an example, I will use a Phobos class: std.demangle.MangleException is private in its module; yet I can use it in my program: import std.demangle; void main() {

Re: dmd crash help

2010-02-03 Thread Lars T. Kyllingstad
strtr wrote: BCS Wrote: Hello Strtr, If you can try it on linux it's not to hard to build a debug version of dmd and run it under the debugger. That will at least give you a filename/line number for the bug report and with a little thinking and a stack trace you can take a guess at what

Re: DMD on x86_64

2010-02-16 Thread Lars T. Kyllingstad
Robert Clipsham wrote: On 15/02/10 21:44, Jesse Phillips wrote: Robert Clipsham wrote: I've been wanting to try D2 properly for a while now, but as I use linux x86-64 I've had to resort to using a virtual machine, which is really off putting when I just want to play around with it. I've read

Re: DMD on x86_64

2010-02-17 Thread Lars T. Kyllingstad
Robert Clipsham wrote: I've been wanting to try D2 properly for a while now, but as I use linux x86-64 I've had to resort to using a virtual machine, which is really off putting when I just want to play around with it. I've read multiple threads about getting dmd working with a multilib

Re: Running external program from a D program [D2]

2010-02-22 Thread Lars T. Kyllingstad
Jonathan M Davis wrote: Okay, I'm looking to be able to run an external program from within my D program. The library functions for this appear to be in std.process. You have system() and various versions of execv(). system() makes a call in shell. execv() executes the program without a shell.

Re: Commmandline arguments and UTF8 error

2010-02-22 Thread Lars T. Kyllingstad
Nils Hensel wrote: Daniel Keep schrieb: If you look at the real main function in src\phobos\internal\dmain2.d, you'll see this somewhere around line 109 (I'm using 1.051, but it's unlikely to be much different in an earlier version): for (size_t i = 0; i argc; i++) { auto len =

Re: Commmandline arguments and UTF8 error

2010-02-22 Thread Lars T. Kyllingstad
Lars T. Kyllingstad wrote: Nils Hensel wrote: Daniel Keep schrieb: If you look at the real main function in src\phobos\internal\dmain2.d, you'll see this somewhere around line 109 (I'm using 1.051, but it's unlikely to be much different in an earlier version): for (size_t i = 0; i argc; i

Re: When is array-to-array cast legal, and what does actually happen?

2010-02-23 Thread Lars T. Kyllingstad
Daniel Keep wrote: ... I see that neither the constructor nor the postblit is called. Apparently the bit representation is used. This has the risk of violating struct invariants. Is it legal? Thank you, Ali cast is to value conversions what a tactical nuclear strike is to peaceful

Re: Converting between string and const char*

2010-03-03 Thread Lars T. Kyllingstad
Robert Clipsham wrote: Hi all, I'm playing with D2/Phobos, and was wondering what the right way to convert between const char* and string is? In D1/Tango I could use toStringz() and fromStringz() from tango.stdc.stringz, I can only find an equivalent for toStringz in D2/Phobos though, in

Re: D2: std.algorithm.find, but get part before what you were searching for

2010-03-04 Thread Lars T. Kyllingstad
Jonathan M Davis wrote: std.algorithm.find() returns the rest of the range starting at what you were searching for (or an empty range if it wasn't in the given range). Is there a function in phobos which does a find but returns everything _before_ what you're searching for? I can't find one

Re: D2: std.algorithm.find, but get part before what you were searching for

2010-03-04 Thread Lars T. Kyllingstad
Jonathan M Davis wrote: Lars T. Kyllingstad wrote: Jonathan M Davis wrote: std.algorithm.find() returns the rest of the range starting at what you were searching for (or an empty range if it wasn't in the given range). Is there a function in phobos which does a find but returns everything

Re: std.file vs std.stream

2010-03-04 Thread Lars T. Kyllingstad
Ludovic A. wrote: Hej, thanks! First I want to underline that I use Digital Mars D Compiler v2.040, and my 2 examples are _working_ examples with this compiler. So I really mean that std.file is working on the last D compiler :) I felt that those examples didn't 'smell' like D, and I also got

Re: std.file vs std.stream

2010-03-04 Thread Lars T. Kyllingstad
Ali Çehreli wrote: Lars T. Kyllingstad wrote: What you're seeing here is actually a consequence of Phobos very much being a work-in-progress. std.stdio was completely rewritten about a year ago, and it most likely contains what you're looking for. std.stream, on the other hand

Re: Static attributes aren' immutable

2010-03-05 Thread Lars T. Kyllingstad
bearophile wrote: I'm playing some more with immutables in D2. This program compiles: struct Foo { static int x; } void main() { immutable Foo f; Foo.x++; f.x++; } Is this code supposed to be correct? If I have an immutable struct I want all of it to be immutable... Bye and

Re: range properties that work in foreach

2010-03-06 Thread Lars T. Kyllingstad
Michael Rynn wrote: On the D2 online pages (http://www.digitalmars.com/d/2.0/statement.html#ForeachStatement)there is Foreach over Structs and Classes with Ranges My question is , is there a working example of foreach ( e ; range )? Iteration over struct and class objects can be done

Re: range properties that work in foreach

2010-03-06 Thread Lars T. Kyllingstad
Lars T. Kyllingstad wrote: Michael Rynn wrote: On the D2 online pages (http://www.digitalmars.com/d/2.0/statement.html#ForeachStatement)there is Foreach over Structs and Classes with Ranges My question is , is there a working example of foreach ( e ; range )? Iteration over struct

Re: using D with C++

2010-03-08 Thread Lars T. Kyllingstad
Nical wrote: Hi, I'm trying to use C/C++ functions in a D program but I cant get it to compile. I tried the exemple of digital mars's website: // file.cpp #include iostream using namespace std; int foo(int i, int j, int k) { cout i = i endl; cout j = j endl; cout k =

  1   2   >