Re: learn D & TDPL

2012-01-23 Thread Daniel Murphy
"Jonathan M Davis" wrote in message news:mailman.659.1327175391.16222.digitalmars-d-le...@puremagic.com... > > It's partially available. It just isn't fully implemented, and I don't > know > what's missing from it. And I have no idea when it will be fully > implemented. > You can certainly use

Re: learn D & TDPL

2012-01-23 Thread Daniel Murphy
"Jonathan M Davis" wrote in message news:mailman.659.1327175391.16222.digitalmars-d-le...@puremagic.com... > It's partially available. It just isn't fully implemented, and I don't > know > what's missing from it. And I have no idea when it will be fully > implemented. > You can certainly use it

Re: Definition of extern(System)?

2012-01-25 Thread Daniel Murphy
"Jonathan M Davis" wrote in message news:mailman.11.1327521278.25230.digitalmars-d-le...@puremagic.com... > As http://d.puremagic.com/issues/show_bug.cgi?id=4788 points out, > extern(System) isn't properly documented, so I have no idea what it > translates > to. Does anyone know what exactly it

Re: TypeTuple of functions

2012-01-26 Thread Daniel Murphy
Differing part: FNaNb xdZ d6 PFNaNbNfxdZxd6 P -> pointer Nf -> @safe x -> const The second one is a function pointer not a function, is inferred to be @safe, and inferred to return const(double). "bearophile" wrote in message news:jfs683$2mqh$1...@digitalmars.com... > I'm asking questions

Re: GC and void*

2012-01-27 Thread Daniel Murphy
Have you looked at std.variant? It sounds like what you're looking for.

Re: delete and MmFile

2012-01-28 Thread Daniel Murphy
"NewName" wrote in message news:jg2du7$2nun$1...@digitalmars.com... > Hello everybody. > So I heard that `delete' is being deprecated? > When delete is gone, you will still be able to destroy class instances with 'clear' from phobos. Like delete, it runs the destructor on the class, it just d

Re: delete and MmFile

2012-01-28 Thread Daniel Murphy
Yes. clear is in object.d so it will always be available. "NewName" wrote in message news:jg2fdj$2rmk$1...@digitalmars.com... > Thanks Daniel. > So clear() is a function thing, so my delete mmf; will look like > clear(mmf); am I > right? >

Re: Pure Contract bug? (unnecessarily strict)

2012-01-28 Thread Daniel Murphy
The way to avoid purity checking is to put code in a debug {} statement. I'm not aware of any plans to disable purity checking for contracts.

Re: combine different data type

2012-01-30 Thread Daniel Murphy
"Simen Kjærås" wrote in message news:op.v8wj38qf0gp...@biotronic.lan... > On Mon, 30 Jan 2012 13:58:38 +0100, sami wrote: > >> when i do that auto x = [1, "ha"]; >> i have an error Error: incompatible types for ((1) ? ("hgh")): 'int' and >> 'string' >> if there any method to combine different d

Re: Function signature constraint syntax

2012-02-02 Thread Daniel Murphy
void func(alias G)(object O) if (is(typeof(G(O)) == void)) { "H. S. Teoh" wrote in message news:mailman.295.1328245356.25230.digitalmars-d-le...@puremagic.com... > Quick question: I have a function that takes an alias parameter: > > struct X { ... }; > > void func(alias G)(object O) { > ... > X

Re: char[] and wchar[] cannot be used as OutputRange

2012-02-03 Thread Daniel Murphy
char[] and wchar[] could still define a put method, which would make them output ranges. This is worth a bug report. "Ali Çehreli" wrote in message news:jgh4a1$1286$1...@digitalmars.com... > This I knew: Being UTF-8 and UTF-16 encodings, and because those encodings > are variable-width, char[

Re: Segment violation (was Re: Why I could not cast string to int?)

2012-02-03 Thread Daniel Murphy
"bearophile" wrote in message news:jgi3jn$2o6p$1...@digitalmars.com... > I'd like to ask this to be valid, to shorten my code: > alias immutable imm; > Is this silly? > Yes =) immutable might be more characters than you want to type, but at this point it's extremely unlikely it will be changed

Re: Associative array literal is non-constant?

2012-02-03 Thread Daniel Murphy
A limitation of the current implementation. Associative arrays are built on the heap, and you can't currently build things on the heap and have them exist at runtime. The best current workaround is probably: static int[string] table; static this() { table = ["abc":1, "def":2, "ghi":3]; } or

Re: Function returning pointer to itself

2012-02-05 Thread Daniel Murphy
Return a struct containing a function pointer. "Tobias Pankrath" wrote in message news:jglvvq$7jr$1...@digitalmars.com... > Is there any better way to write a function that can return a pointer to > itself than returning void* and cast at call site to the appropiate type? >

Re: Struct "inheritance"

2012-02-05 Thread Daniel Murphy
"Vidar Wahlberg" wrote in message news:jgm2qk$c2g$1...@digitalmars.com... > Adding a note about GDC (4.6.2) here: > It appears like it ignores "module ;" and always use the filename > for module name (or I've misunderstood what "module" is used for). If I > create a file "Foo.d" which contains

Re: Struct "inheritance"

2012-02-05 Thread Daniel Murphy
I guess you've found a bug then. :) "Vidar Wahlberg" wrote in message news:jgm7sh$k4u$1...@digitalmars.com... > On 2012-02-05 15:19, Daniel Murphy wrote: >> The names only need to match if the compiler/build tool has to find the >> module itself. If you call

Re: Purity and enum

2012-02-06 Thread Daniel Murphy
"simendsjo" wrote in message news:jgo9if$1mg9$1...@digitalmars.com... > Should purity be checked at all if used with an enum? I don't think so. http://d.puremagic.com/issues/show_bug.cgi?id=6169 https://github.com/D-Programming-Language/dmd/pull/652

Re: Purity and enum

2012-02-06 Thread Daniel Murphy
I wouldn't hold my breath. "simendsjo" wrote in message news:jgoejk$23j1$1...@digitalmars.com... > On 02/06/2012 11:46 AM, Daniel Murphy wrote: >> "simendsjo" wrote in message >> news:jgo9if$1mg9$1...@digitalmars.com... >>> Should purity be c

Re: Mixture of type tuple and expression tuple

2012-02-06 Thread Daniel Murphy
http://d.puremagic.com/issues/show_bug.cgi?id=2599 "Matthias Walter" wrote in message news:mailman.71.1328567829.20196.digitalmars-d-le...@puremagic.com... > Hi, > > I'd like to have a function foo which shall depend on several > compile-time expressions (e.g. strings) and gets several arguments

Re: Could use some help with porting problems

2012-02-07 Thread Daniel Murphy
It seems the problem you've run into is that a class reference cannot be tail-const. Pointers can be tail-const like this: const(Data)* but there is no way currently (there are proposals) to make only the data and not the reference const. A workaround is to use Rebindable in std.typecons. An a

Re: Stride

2012-02-14 Thread Daniel Murphy
"Jonathan M Davis" wrote in message news:mailman.306.1329166430.20196.digitalmars-d-le...@puremagic.com... > Ideally perhaps, but I expect that that's not true, because operator > overloading is done via lowering. > > foo() ~ bar() > > would become > > opBinary!"~"(foo(), bar()); > While your po

Re: More octal questions

2012-02-17 Thread Daniel Murphy
"Jonathan M Davis" wrote in message news:mailman.508.1329531876.20196.digitalmars-d-le...@puremagic.com... > > They have nothing to do with octal in that they were not intentionally > octal. > I was merely using the leading 0 without thinking about it, because having > leading 0s generally makes

Re: Everything on the Stack

2012-02-21 Thread Daniel Murphy
scope/scoped isn't broken, they're just not safe. It's better to have an unsafe library feature than an unsafe language feature.

Re: Dumb question about git

2012-03-01 Thread Daniel Murphy
Unless you have an expectation that other people are already using the old version of your branch, just use 'git push blah -f' to overwrite the old version. It's not a big deal for patches and pull requests, but it would be a disaster if anyone did this to the master branch. "H. S. Teoh" wrot

Re: How to avoid code duplication in static if branches?

2012-03-03 Thread Daniel Murphy
"Andrej Mitrovic" wrote in message news:mailman.364.1330825349.24984.digitalmars-d-le...@puremagic.com... > import std.stdio; > void check() { writeln("check"); } > > struct Foo { bool isTrue = true; } > struct Bar { } > > void test(T)(T t) > { >static if (is(T == Foo)) >{ >if (t.

Re: Some compile time help..

2012-03-04 Thread Daniel Murphy
"simendsjo" wrote in message news:op.wanctrbux8p62v@simendsjo-desktop... > Hi. > I have the following code: > void f(Args...)(Args args) { > needs_wchar_t(args); > } > > I want to loop over Args, and if it's a string of some type, I want to run > it through toUTFz. For all other values, I jus

Re: [Inline assembler] Sequential `asm` blocks and return via EAX

2012-03-08 Thread Daniel Murphy
"Denis Shelomovskij" wrote in message news:jj9uv1$8o$1...@digitalmars.com... > 1. Is there any guaranties that no code will be added between sequential > inline assembler blocks, e.g.: > --- > void f() > { > static if(x) > asm { mov EBX, 3; } > else > asm { mov EBX, 7; }

Re: Confused about github rebasing

2012-03-15 Thread Daniel Murphy
"H. S. Teoh" wrote in message news:mailman.719.1331847338.4860.digitalmars-d-le...@puremagic.com... > Actually, I discovered that my origin/master branch was also broken > (probably due to running the wrong git command in it in the past), > because it had a bunch of commits from upstream that fo

Re: std.file bug? std.regex bug?

2010-06-26 Thread Daniel Murphy
It could be that the string returned from the regex looks the same as the hardcoded string but contains characters that don't show up when you print it. Does adding assert(regexResult == expectedFilename); throw? "Simen kjaeraas" wrote in message news:op.vewf53itvxi...@biotronic-pc.lan... >I hav

Re: CT usage only in executable

2010-07-16 Thread Daniel Murphy
"strtr" wrote in message news:i1lro6$307...@digitalmars.com... > == Quote from bearophile (bearophileh...@lycos.com)'s article >> strtr: >> > Not that the memory is really significant compared to the rest of my >> > program, >> > but I have a few fairly large arrays I use only in compile time and

Re: CT usage only in executable

2010-07-16 Thread Daniel Murphy
"strtr" wrote in message news:i1ql53$306...@digitalmars.com... > == Quote from Daniel Murphy (yebbl...@nospamgmail.com)'s article >> I think if you use enum instead of const/immutable the compiler is not >> meant >> to put them in the executable (it mi

Re: importing std.algorithm breaks std.string.count

2010-09-22 Thread Daniel Murphy
"Steven Schveighoffer" wrote in message news:op.vi64pdhveav...@localhost.localdomain... > Second, std.algorithm.count looks like this: > > size_t count(alias pred = "a == b", Range, E)(Range r, E value) if > (isInputRange!(Range)) > > So, E can be any type, completely unrelated to strings, I cou

Re: How to use a member function (delegate) as a function pointer

2010-10-31 Thread Daniel Murphy
"Peter Federighi" wrote in message news:ial8hq$213...@digitalmars.com... > Is there a way to do it without removing handler() from the class? When I > try > compiling, I get: Error: cannot implicitly convert expression > (&this.handler) > of type void delegate(int signal) to void C function(in

Re: segfault

2010-11-10 Thread Daniel Murphy
What happens if you make pattern const?

Re: Switch constants

2010-11-13 Thread Daniel Murphy
"bearophile" wrote in message news:ibn320$2uc...@digitalmars.com... > In a not-ranged cases body, like in the program below (that doesn't > compile), the switch variable is a compile-time constant, so why doesn't > the compile see x as constant there? In switch statements, you can do stuff lik

Re: BufferedFile.write

2010-11-19 Thread Daniel Murphy
"Tom" wrote in message news:ic7nq3$6i...@digitalmars.com... > Do I have to do this? > > file.write(cast(string)"hello"); You can set the type of a string literal using a suffix: "hello"c - string "hello"w - wstring "hello"d - dstring

Re: namespace (for export)

2010-11-25 Thread Daniel Murphy
I might be off track, but I think I know what you're getting at. You want to define a set of module scope variable that are initialized when the program starts up: eg. A struct that stores information loaded from a configuration file (can't be done at compile time) module foo; struc

Re: function pointers in D2

2010-12-12 Thread Daniel Murphy
"Christopher Nicholson-Sauls" wrote in message news:ie28aa$18b...@digitalmars.com... > This > surprises me, and certainly has to be a bug. > http://d.puremagic.com/issues/show_bug.cgi?id=3797

Re: Assigning Interface to Object

2011-01-23 Thread Daniel Murphy
"Mandeep Singh Brar" wrote in message news:ihf3gs$2kve$1...@digitalmars.com... > Hi, > > I was just thinking if implementing interfaces as abstract classes could > be a workaround. Since D anyways allows multiple inheritance, so would it > make sense > to just declare interfaces as abstract cla

Re: Assigning Interface to Object

2011-01-23 Thread Daniel Murphy
"Andrej Mitrovic" wrote in message news:mailman.764.1295584412.4748.digitalmars-d-le...@puremagic.com... > Speaking of COM.. has anyone successfully used COM interfaces in D2? > I'm asking because a few months ago I gave them a try but I kept > having random access violations. And I *do* mean ran

Re: concatenation

2011-01-26 Thread Daniel Murphy
"Ellery Newcomer" wrote in message news:ihl0vh$1n8v$1...@digitalmars.com... > in the following: > > void main(){ > char[] x; > string s; > string y; > > y = s ~ x; > } > > tok.d(5): Error: cannot implicitly convert expression > (cast(const(char)[])s ~ x) of type char[] to string > > why

Re: foreach over string enum

2011-02-20 Thread Daniel Murphy
"Jesse Phillips" wrote in message news:ij2drt$1mq3$1...@digitalmars.com... > > Magic. > > No really, the best I can tell is that the compiler will try to run the > foreach loop at compile-time if there is something in the body that must > be evaluated at compile time. > Actually this happens b

Re: Can't figure out segfault

2011-03-02 Thread Daniel Murphy
Assuming you've checked that dlopen isn't returning null, I can't find the source of the error in that code, sorry. Unsolicited advice: Is there any reason you're manually loading the dll rather than using an import library? A couple of remarks about the rest of the code: Generally in D the c

Re: Linker errors on OSX

2011-06-19 Thread Daniel Murphy
"Peter Alexander" wrote in message news:itlk5g$e7t$1...@digitalmars.com... > I've been having strange linker errors recently and I have no ideas why > they've started happening. > > Undefined symbols: > "_D3std9exception7bailOutFAyaixAaZv", referenced from: > _D3std9exception148__T7enforceTb

Re: Scale advocacy

2011-07-04 Thread Daniel Murphy
"Ali Çehreli" wrote in message news:iuqja8$7nl$2...@digitalmars.com... > { bool result = ElementType!Range.init is null; } )) is(typeof(ElementType!Range.init is null)) __traits(compiles, cast(void)ElementType!Range.init is null) __traits(compiles, { return ElementType!Range.init is null; }) sho

Re: swap doesn't work in CTFE?

2011-07-04 Thread Daniel Murphy
"Johann MacDonagh" wrote in message news:iusp80$vnr$1...@digitalmars.com... > Although CTFE supports ref parameters, swap doesn't appear to work. This > casues dmd to segfault in 2.053 and the current dmd master. > > import std.algorithm; > import std.stdio; > > string ctfeRef(ref string a, ref

Re: swap doesn't work in CTFE?

2011-07-04 Thread Daniel Murphy
"bearophile" wrote in message news:iut093$1bjg$1...@digitalmars.com... > Daniel Murphy: > >> Same thing happens with pointers. Reduced: > > Pointers to structs in CTFE will work in DMD 2.054 :-) When they don't crash the compiler, that is. http://d.puremagic.com/issues/show_bug.cgi?id=6250

Re: Postblit not called in one case

2011-07-06 Thread Daniel Murphy
Looks like a bug. Please file. "bearophile" wrote in message news:iv0eki$1d8e$1...@digitalmars.com... > With DMD 2.053 the second assert of this program fires, is this a DMD bug > or it's me that's missing something? > > > struct Foo { >int[] data; > >this(int n) { >data.length

Re: Any way to get the name of a function?

2011-07-06 Thread Daniel Murphy
Maybe something like TypeTuple!(foo ,bar) will work. "Andrej Mitrovic" wrote in message news:mailman.1452.1310006894.14074.digitalmars-d-le...@puremagic.com... > void foo(){}; > void bar(){}; > > void main() > { >auto funcs = [&foo, &bar]; > } > > I'm using this in a foreach loop and invoki

Re: This seems like what could be a common cause of bugs

2011-07-09 Thread Daniel Murphy
"Steven Schveighoffer" wrote in message news:op.vybo0hv1eav7ka@localhost.localdomain... > 1. is a horrible legacy thing, and should be removed. > > -Steve This I hate, but I'd hate to lose 1.f and 1.L

Re: This seems like what could be a common cause of bugs

2011-07-11 Thread Daniel Murphy
"Steven Schveighoffer" wrote in message news:op.vygk71eweav7ka@localhost.localdomain... > > What's wrong with 1.0f and 1.0L ? > > -Steve It's one character longer! Mostly it's just a habit I've gotten into. I'd likely be able to get used to writing the zero fairly easily.

Re: This seems like what could be a common cause of bugs

2011-07-11 Thread Daniel Murphy
"Steven Schveighoffer" wrote in message news:op.vygm6auqeav7ka@localhost.localdomain... > > 1f is one character shorter :P (BTW, not sure the grammar currently > supports this one, even though it compiles. I think: > > Integer FloatSuffix > > should be added. > > I admit, there is no equivalent

Re: Declaring a D pointer to a C function

2011-07-13 Thread Daniel Murphy
"Andrej Mitrovic" wrote in message news:mailman.1569.1310506439.14074.digitalmars-d-le...@puremagic.com... > Is this going to be fixed any time soon? Allowing callbacks with D > calling convention where a C callback is expected should be an error, > and this is like the 10th time I've ran into th

Re: Declaring a D pointer to a C function

2011-07-13 Thread Daniel Murphy
"Andrej Mitrovic" wrote in message news:mailman.1607.1310570915.14074.digitalmars-d-le...@puremagic.com... > Thanks! I've literally lost an entire day once when I was just > starting using D and C together and had a calling convention mismatch. > :x It's worse than just calling conventions - try

Re: A problem with const

2011-07-14 Thread Daniel Murphy
Yeah, type deduction with modifiers is inconsistent. In some cases matching T to const(U) gives U == tailconst(T), but not in others. The problem exists with pointers, arrays, and (if we ever get it) Michel Fortin's const(Object)ref. A big part of the problem is that it can match with implicit

Re: A problem with const

2011-07-14 Thread Daniel Murphy
I don't think there's a bug report specifically on this. "bearophile" wrote in message news:ivmigl$98a$1...@digitalmars.com... > Daniel Murphy: > >> Yeah, type deduction with modifiers is inconsistent. >> >> In some cases matching T to const(U) g

Re: wrapping a void* by a ubyte[] array?

2011-07-14 Thread Daniel Murphy
Cast to ubyte* and slice? ubyte[] array = (cast(ubyte*)pointer)[0..length]; "teo" wrote in message news:ivn0n8$14ig$1...@digitalmars.com... > Is there any way of wrapping a void* by a ubyte[] array? The void* comes > from mmap.

Re: Comparing floating point: == vs is

2011-07-16 Thread Daniel Murphy
"Jonathan M Davis" wrote in message news:mailman.1687.1310805329.14074.digitalmars-d-le...@puremagic.com... > Under what circumstances would a comparison of floating point values > return > true for is but not ==? If I understand corcectly, is does a bit-by-bit > comparison. So, I would expect t

Re: Comparing floating point: == vs is

2011-07-16 Thread Daniel Murphy
I'd recommend using Don's isIdentical (or something like that) in std.math until it's fixed.

Re: Comparing floating point: == vs is

2011-07-16 Thread Daniel Murphy
"Jonathan M Davis" wrote in message news:mailman.1689.1310808023.14074.digitalmars-d-le...@puremagic.com... > Hmm. Good to know. But assuming that two floating point values have the > same > bit pattern, shouldn't == return true for them? So, if == is failing, then > two > floating point values

Re: Comparing floating point: == vs is

2011-07-16 Thread Daniel Murphy
"Jonathan M Davis" wrote in message news:mailman.1690.1310809801.14074.digitalmars-d-le...@puremagic.com... > I tried both casting to an integer of the appropriate size and swapping > that > and doing this: > > private T swapEndianImpl(T)(T val) >if(isFloatingPoint!T) > { >import std.alg

Re: Comparing floating point: == vs is

2011-07-16 Thread Daniel Murphy
"Jonathan M Davis" wrote in message news:mailman.1705.1310853321.14074.digitalmars-d-le...@puremagic.com... > I suspect that the problem is a combination of issues with NaN and real. > If I > change the first three tests (which test init which is NaN) to is, then > they > pass, but the test for

Re: Comparing floating point: == vs is

2011-07-17 Thread Daniel Murphy
"Jonathan M Davis" wrote in message news:mailman.1708.1310882400.14074.digitalmars-d-le...@puremagic.com... > I'm on Linux. > > I need to do whatever will result in the correct value with == if that is > at > all possible. The question the is twofold: > > 1. How to make it so that swapping the e

Re: Scope of lambdas and closures

2011-07-17 Thread Daniel Murphy
That would be http://d.puremagic.com/issues/show_bug.cgi?id=2634 "Rolv Seehuus" wrote in message news:ivug6b$o7o$1...@digitalmars.com... > Hi all, > > First post - I'm learning D, 10yrs exp. with C++. > > While trying to generate a static table of functions using lambdas compile > time using mi

Re: Scope of lambdas and closures

2011-07-19 Thread Daniel Murphy
"Rolv Seehuus" wrote in message news:j04qff$i4s$1...@digitalmars.com... > Is there a related/same reason why this don't compile? > > unittest { > static void stuff(){} > static void function()[string] functions = [ "stuff":&stuff ]; > } That compiles for me.

Re: Using templates to declare function prototypes

2011-07-30 Thread Daniel Murphy
Use extern(System)? "Heinz" wrote in message news:j12hkk$2mcd$1...@digitalmars.com... > Hello D community!!! > > I'm porting the NVIDIA CUDA headers to D. The CUDA platform runs on > multiple > OS, so functions prototypes (in the D way) are declared as > "extern(Windows) > ..." for MS Windows

Re: Using templates to declare function prototypes

2011-07-30 Thread Daniel Murphy
It is documented! http://www.digitalmars.com/d/1.0/attribute.html#linkage http://www.digitalmars.com/d/2.0/attribute.html#linkage "Heinz" wrote in message news:j12itk$2o99$1...@digitalmars.com... > Thanks, extern(System) seems to do the job under windows at least, i hope > it > switch to extern

Re: Problem with take(map())

2011-07-30 Thread Daniel Murphy
The problem is the parameter p is not being heap allocated. I'm fairly sure it's already in bugzilla, something about failing to detect escaping references with alias parameters. "bearophile" wrote in message news:j0vhod$t87$1...@digitalmars.com... > D2 code: > > > import std.stdio, std.algor

Re: Copying a variable state in a delegate literal definition

2011-09-02 Thread Daniel Murphy
"Andrej Mitrovic" wrote in message news:mailman.2651.1315000369.14074.digitalmars-d-le...@puremagic.com... > On 9/2/11, Steven Schveighoffer wrote: >> Am I missing something, or is it this simple? >> >> void appendMenuButton() >> { >> static size_t menuIndex; >> auto frameIndex = menuInd

Re: Implicit cast rules of dynamic array

2011-09-03 Thread Daniel Murphy
No, this is http://d.puremagic.com/issues/show_bug.cgi?id=4953 "Erik Baklund" wrote in message news:j3u33n$1f87$1...@digitalmars.com... > Hi, > > Do anybody know if the implicit casting rules of float[] in the example > below, > works as intended? > > E. > > -- > > // dmd v2.054 > module main;

Re: Implicit cast rules of dynamic array

2011-09-04 Thread Daniel Murphy
The good news is there are two possible patches that should fix it. "Erik Baklund" wrote in message news:j3v9dk$ero$1...@digitalmars.com... > Thanks! > Ouch, the regression is still not fixed after almost one year. > I have put a vote on it. > E.

Re: attribute decl in version decl

2011-09-19 Thread Daniel Murphy
"Ellery Newcomer" wrote in message news:j557r6$vgt$1...@digitalmars.com... > Just came across some old D code that does this: > > version(linux){ > extern(C): > } > Are the prototypes extern(Windows) when not on linux, by any chance? That is the only combination I've ever had to use, and is su

Re: const->immutable array argument?

2011-09-20 Thread Daniel Murphy
"Steven Schveighoffer" wrote in message news:op.v13w8td2eav7ka@localhost.localdomain... > On Tue, 20 Sep 2011 07:33:20 -0400, bearophile > wrote: > >> void foo(const ref int[5] a) {} >> void main() { >> immutable int[5] arr; >> foo(arr); // Error? >> } > > The complaint from the compile

Re: Using pure to create immutable

2011-09-23 Thread Daniel Murphy
"Jesse Phillips" wrote in message news:j5gfsa$2d5g$1...@digitalmars.com... > Thank you this lets it compile. I think I had that somewhere, but forgot > about it. As Steve mentions, it probably should also work for const > arguments too. It probably will, eventually. Some expressions can be pr

Re: Any way to expand a tuple?

2011-09-24 Thread Daniel Murphy
"Andrej Mitrovic" wrote in message news:mailman.142.1316903007.26225.digitalmars-d-le...@puremagic.com... > > Is it possible to expand the phobos tuple in the call to test()? I can > use the isTuple template in a `static if` to figure out if it needs > expansion, so all that's left is to actually

Re: Implicit cast to immutable

2011-10-15 Thread Daniel Murphy
The implicit conversion to immutable is only possible inside strongly pure functions. When the parameter is 'in int[]' foo cannot be strongly pure, only const pure. As 'in int[2]' is a value type, the second foo can be strongly pure. 'new' expressions will hopefully be able to be converted to

Re: Implicit cast to immutable

2011-10-17 Thread Daniel Murphy
"Steven Schveighoffer" wrote in message news:op.v3h06olweav7ka@localhost.localdomain... > > That sounds like an incorrect restriction. The implicit cast to immutable > should depend on whether the function being *called* qualifies, not if the > function you are calling *from* qualifies. > I t

Re: Implicit cast to immutable

2011-10-18 Thread Daniel Murphy
"bearophile" wrote in message news:j7jepi$prp$1...@digitalmars.com... > Daniel Murphy: > >> 2) >> immutable(int[]) fun() { return new int[]; } // conversion happens here >> immutable x = fun(); >> >> Bearophile's example is of the second, wh

Re: Implicit cast to immutable

2011-10-19 Thread Daniel Murphy
"Steven Schveighoffer" wrote in message news:op.v3lug2q2eav7ka@localhost.localdomain... > On Tue, 18 Oct 2011 02:40:12 -0400, Daniel Murphy > wrote: > >> "Steven Schveighoffer" wrote in message >> news:op.v3h06olweav7ka@localhost.localdomain

Re: pure vs writeln debugging

2014-02-11 Thread Daniel Murphy
"Jesse Phillips" wrote in message news:vaatltklsmbmdnabo...@forum.dlang.org... Wish it would work with @safe and nothrow too, granted writeln should eventually be @safe/trusted anyway. I just travelled back in time and granted your wish! int x; int* p; void main() pure nothrow @safe {

Re: Colons and brackets

2014-03-02 Thread Daniel Murphy
"evilrat" wrote in message news:mxhmgkljrzqhaymec...@forum.dlang.org... On Friday, 28 February 2014 at 04:19:47 UTC, Etienne Cimon wrote: > > How do you stop statements from belonging to the specific version of > code without using brackets? add "version(all):" after code where specific versi

Re: How can I specify a location to write the code coverage files generated with '-cov'?

2014-04-04 Thread Daniel Murphy
On Friday, 4 April 2014 at 04:10:51 UTC, Saurabh Das wrote: Hello, Say I compile a program with: dmd -unittest -debug -cov test.d Then, when I run ./test, a file 'test.lst' is generated in the current working directory. Is there a way in which I can instruct the file to be created in a separ

Re: Anyone have sucess converting MSVC 2010 COFF libs to OMF

2014-04-09 Thread Daniel Murphy
"Byron" wrote in message news:li1ba2$5lc$1...@digitalmars.com... So does anyone have a fool prof way of converting coff to omf libs. I feel like this use to be easy.. In general, this won't work. The only thing that is straightforward and reliable is converting coff import libraries to omf

Re: Implicit conversions through purity

2014-04-13 Thread Daniel Murphy
"Jonathan M Davis" wrote in message news:mailman.112.1397351369.5999.digitalmars-d-le...@puremagic.com... Honestly, I would have considered that to be a bug. Converting the return type to a different level of mutability based on purity is one thing. Automatically casting the return value just

Re: Implicit conversions through purity

2014-04-13 Thread Daniel Murphy
"bearophile" wrote in message news:hxdrbyqrhwvuochlh...@forum.dlang.org... Is it possible and a good idea to allow code like the function foo2? It seems reasonable.

Re: template specialization question

2010-01-31 Thread Daniel Murphy
daoryn Wrote: > According to http://digitalmars.com/d/2.0/template.html it is possible to > specify template specialization so that DMD prefers them when instanciating > templates, however the following code: > > > - > import std.stdio; > > void print(T)(T thin

Re: Template instantiation without (...)

2010-02-07 Thread Daniel Murphy
Steve Teale Wrote: > Which bit of the spec for template instantiation is it that allows the > last two lines of the following to compile and work? > > import std.stdio; > > > struct A > { > int a; > } > > template Thingie(T) > { > static if (is(T == int)) > enum Thingie = 1; >

Re: Unexpected behaviour on socket

2010-02-09 Thread Daniel Murphy
Gythzel Wrote: > (relating code at http://dpaste.com/156595/ on D2) > > This is a very trimmed version of something I'm experimenting with, so the > design of the code is not the issue. The problem is what happens on the > "accepter" function. > > After the Socket.select returns 1 (meaning, 1

Re: Passing dynamic arrays into C.

2010-04-25 Thread Daniel Murphy
It should work if you treat the dynamic array like a pointer and a length. eg: glBufferData(GL_ARRAY_BUFFER, (vertices[0]).sizeof * vertices.length, vertices.ptr, GL_STATIC_DRAW); It's probably because (type).sizeof gives the number of bytes to hold the type. For dynamic arrays

Re: Something about Chinese Disorder Code

2015-12-01 Thread Daniel Murphy via Digitalmars-d-learn
On 25/11/2015 2:16 PM, Rikki Cattermole wrote: On 25/11/15 1:47 AM, Meta wrote: I'm pretty sure you can just do: wstring text = "my string"; Or auto text = "my string"w; The second one is correct yes. I'm just assuming that it isn't compiled into the executable. Either is fine. Non-suffi

Re: Can someone check this on win32 ?

2015-12-01 Thread Daniel Murphy via Digitalmars-d-learn
On 21/11/2015 10:46 PM, BBaz wrote: Seems to be fixed: __ import std.math; void main() {real function(real) c = &sin;} __ https://issues.dlang.org/show_bug.cgi?id=4541 At least it works on linux x86_64. It works because of https://github.com/D-Prog

Re: Reset all Members of a Aggregate Instance

2015-12-07 Thread Daniel Murphy via Digitalmars-d-learn
On 4/12/2015 8:38 AM, Chris Wright wrote: An object reference is just a pointer, but we can't directly cast it. So we make a pointer to it and cast that; the type system allows it. Now we can access the data that the object reference refers to directly. Casting is fine too: cast(void*)classRef

Re: Any chance to avoid monitor field in my class?

2014-05-13 Thread Daniel Murphy via Digitalmars-d-learn
"Yuriy" wrote in message news:uflaemdlxvavfmvkb...@forum.dlang.org... Hello, is there a way of reducing size of an empty class to just vtbl? I tried to declare it as extern(C++) which works, but has a nasty side effect of limited mangling. What exactly is the mangling problem with extern(C++

Re: Any chance to avoid monitor field in my class?

2014-05-14 Thread Daniel Murphy via Digitalmars-d-learn
On Tuesday, 13 May 2014 at 17:41:42 UTC, Yuriy wrote: On Tuesday, 13 May 2014 at 17:09:01 UTC, Daniel Murphy wrote: What exactly is the mangling problem with extern(C++) classes? Can't use D arrays (and strings) as function argument types. Can't use D array types as template argument

Re: Any chance to avoid monitor field in my class?

2014-05-15 Thread Daniel Murphy via Digitalmars-d-learn
"Yuriy" wrote in message news:rfirqtgbparjbqxwt...@forum.dlang.org... On Wednesday, 14 May 2014 at 08:47:38 UTC, Daniel Murphy wrote: > I'm not getting any errors with the development head. What os/compiler > version? Hm, now that's strange. Building with latest pu

Re: Any chance to avoid monitor field in my class?

2014-05-16 Thread Daniel Murphy via Digitalmars-d-learn
"Yuriy" wrote in message news:klosrzuxwmvilupzz...@forum.dlang.org... Ok, i can understand that, but what about this one: http://dpaste.dzfl.pl/6a9961e32e6d It doesn't use d arrays in function interfaces. Should it work? Similar problem, D arrays cannot be mangled correctly with C++ mangling.

Re: Building 32bit program with MSVC?

2014-05-31 Thread Daniel Murphy via Digitalmars-d-learn
"Jonathan M Davis via Digitalmars-d-learn" wrote in message news:mailman.1421.1401576730.2907.digitalmars-d-le...@puremagic.com... > By dynamic linking do you mean LoadLibrary or linking with import > library? Both will work, otherwise we couldn't use Microsoft's libraries - e.g. std.windows.

Re: DIP64 - Regarding 'pure' and 'nothrow'

2014-08-28 Thread Daniel Murphy via Digitalmars-d-learn
"Brian Schott" wrote in message news:pbfgiwaxsdxdxetpi...@forum.dlang.org... The "delete" keyword is deprecated[1] and making that decision never broke any code. [1] http://dlang.org/deprecate.html#delete If you look at the table up the top, delete hasn't actually been deprecated yet. If

Re: DIP64 - Regarding 'pure' and 'nothrow'

2014-08-28 Thread Daniel Murphy via Digitalmars-d-learn
"Jonathan M Davis" wrote in message news:xjmfhegvanqdivhbt...@forum.dlang.org... AFAIK, the only reason that it's not deprecated is that no one has bothered to make the change (and you didn't want to deprecate it when you went through all of those and updated their status a while back). Andr

Re: Purity of std.conv.to!string

2015-09-27 Thread Daniel Murphy via Digitalmars-d-learn
On 27/09/2015 3:14 AM, cym13 wrote: On Saturday, 26 September 2015 at 17:08:00 UTC, Nordlöw wrote: Why is the following code not pure: float x = 3.14; import std.conv : to; auto y = x.to!string; ??? Is there a reason for it not being pure? If not, this is a serious problem as thi

  1   2   >