Re: Type inference and overloaded functions

2013-12-11 Thread Timothee Cour
On Wed, Dec 11, 2013 at 5:17 PM, bearophile wrote: > Namespace: > > Your gig: https://github.com/D-Programming-Language/dmd/pull/ >> 2952#discussion_r8288045 >> > > My enhancement request was for the array[$] syntax. The idea of []s was > invented by someone else (T

Re: std.file.dirEntries unsorted

2013-12-11 Thread Timothee Cour
yes, I agree sorting should be explicit as there's no natural order. However sorting after calling dirEntries is not great as typically one wants to sort within a given directory level and it's too late to sort once all the directory levels are flattened. so how about having an extra argument that

std.file.dirEntries unsorted

2013-12-10 Thread Timothee Cour
dirEntries depends on readdir, which has undefined order (eg: http://stackoverflow.com/questions/8977441/does-readdir-guarantee-an-order, and I've experienced as well dirEntries in non-alphabetical order) shouldn't we make dirEntries return in alphabetical order by default, with an option to retur

Re: how to build doc from source?

2013-12-05 Thread Timothee Cour
On Thu, Dec 5, 2013 at 11:40 AM, H. S. Teoh wrote: > On Thu, Dec 05, 2013 at 10:09:59AM -0800, Timothee Cour wrote: > > The instructions in http://wiki.dlang.org/Building_DMD are full of bugs > > (noone bothered to run those apparently), and running make -f posix.mak > &g

how to build doc from source?

2013-12-05 Thread Timothee Cour
The instructions in http://wiki.dlang.org/Building_DMD are full of bugs (noone bothered to run those apparently), and running make -f posix.mak from dlang.org has issues, eg dependency on kindlegen. Furthermore, dlang.org's posix.mak requires a git clone, and clones an entire copy of phobos under

Re: scoped chdir and similar patterns

2013-12-04 Thread Timothee Cour
RAII, of course! thanks! btw, what about A3 above? On Wed, Dec 4, 2013 at 5:14 PM, Jonathan M Davis wrote: > On Wednesday, December 04, 2013 17:07:03 Timothee Cour wrote: > > A1. > > > > Is there a (clever?) way to achieve the following using a single function > >

scoped chdir and similar patterns

2013-12-04 Thread Timothee Cour
A1. Is there a (clever?) way to achieve the following using a single function call? //does chdir void fun(){ ... string dir0=getcwd; scope(exit) chdir(dir0); chdir(dir); ... } //desired: void fun(){ ... chdir_scoped(dir); ... } AST macros should make that easy, but that's not for tomorro

Re: Variable arguments with file and line information?

2013-11-16 Thread Timothee Cour
unfortunately this problem keeps arising every so often and the only thing we have are workarounds to name a few: digitalmars.D - Typesafe variadics in any position feature request: special optional argument (__FILE__, ...) AFTER variadic template On Sat, Nov 16, 2013 at 3:55 PM, Jonathan M Davi

Re: pitfalls of enum

2013-11-15 Thread Timothee Cour
On Thu, Nov 14, 2013 at 5:02 PM, bearophile wrote: > Ali Çehreli: > > > > When is an enum *better* than a normal (static >> const/immutable) constant? >> >> Good question. :) >> > > When you can or want to compute something at compile-time, when you need > values to feed to templates, etc. > > bu

how to handle void arguments in generic programming ?

2013-11-10 Thread Timothee Cour
The code snippet below doesn't work. Is there a way to make it work? import std.stdio; void main(){ writelnIfNonVoid(writeln("ok")); } void writelnIfNonVoid(T...)(T a){ static if(T.length) writeln(a); }

Re: Get variable symbol name that was passed to a paramater?

2013-11-09 Thread Timothee Cour
can your 'inspect' method handle: * multiple arguments? * expressions? I wrote a function that does both, it's one of those things that are very useful for quick debugging: import util.prettyprint; void main(){ int x=23; double y=2.4; writelnL(x,y,x*y); } //output: file test.d:7 { x=int{

Re: improving '$' to work with other functions (eg: indexed)

2013-10-31 Thread Timothee Cour
er 31, 2013 02:46:32 Timothee Cour wrote: > > can we support this and similar use cases ? > > > > import std.range; > > void main(){ > > auto a=[1,2,3,4]; > > auto b1=a.indexed([0,a.length-1]);//OK > > auto b2=a.indexed([0,$-1]);//NG > > } > >

improving '$' to work with other functions (eg: indexed)

2013-10-31 Thread Timothee Cour
can we support this and similar use cases ? import std.range; void main(){ auto a=[1,2,3,4]; auto b1=a.indexed([0,a.length-1]);//OK auto b2=a.indexed([0,$-1]);//NG }

Re: how to tell whether we are running inside a try/catch block?

2013-10-27 Thread Timothee Cour
On Fri, Oct 25, 2013 at 7:16 AM, Ali Çehreli wrote: > On 10/25/2013 04:12 AM, Timothee Cour wrote: > > > the stack would already be unwinded and there'd be no way to go back in > time > > to the point where the relevant exception got thrown. > > Another spot is

Re: How to get a substring?

2013-10-26 Thread Timothee Cour
On Sat, Oct 26, 2013 at 6:24 PM, Nicolas Sicard wrote: > On Sunday, 27 October 2013 at 00:18:41 UTC, Timothee Cour wrote: > >> I've posted a while back a string=>string substring function that doesn't >> allocating: google >> "nonallocating unicode st

Re: How to get a substring?

2013-10-26 Thread Timothee Cour
I've posted a while back a string=>string substring function that doesn't allocating: google "nonallocating unicode string manipulations" code: auto slice(T)(T a,size_t u, size_t v)if(is(T==string)){//TODO:generalize to isSomeString import std.exception; auto m=a.length; size_t i; enforce(u<=v);

how to tell whether we are running inside a try/catch block?

2013-10-25 Thread Timothee Cour
is there a way to tell whether we're running inside a try/catch block, as well as the type T expected by the catch(T) block (and perhaps also file/line info) ? use case: i'd like to customize my exception handler so that if I'm not running in a try/catch block, then I will pause instead of exitin

Re: running a command in a directory using std.process

2013-10-24 Thread Timothee Cour
+1 this is a command use case. Further,relying on shell such as cd subdir && foo is fragile: if it fails, we're not sure whether it's because it couldn't cd to subdir or because of foo. Woudl the following be as efficient? system_in_dir(string dir, string action){ auto path=getcwd scope(exit) c

Re: front evaluated multiple time with joiner depending on where extra arg given

2013-10-22 Thread Timothee Cour
> In general, if you want to do something once per element which involves > side > effects, I would advise using foreach rather than trying to put it into a > range. using foreach breaks UFCS chains, and also ElementType != ForeachType > But if you insist on doing so, the side effect should go

Re: front evaluated multiple time with joiner depending on where extra arg given

2013-10-22 Thread Timothee Cour
> > > Certainly, I'd argue that it's generally better practice to do the work > in popFront, because front does frequently gets called multiple times, and > you > almost always end up calling front if you call popFront. > Actually, the way phobos is designed, often times it's easier to specify wha

front evaluated multiple time with joiner depending on where extra arg given

2013-10-22 Thread Timothee Cour
Does that make sense? feature or bug? void main(){ import std.algorithm; import std.array; { int counter=0; auto b=[1,2,3].map!(a=>{counter++; return [a];}()).joiner([0]).array; assert(counter==3); } { int counter=0; auto b=[1,2,3].map!(a=>{counter++; return [a];}()).

Re: globMatch: distinguish double ** (recursive) vs single *

2013-10-20 Thread Timothee Cour
To clarify, this is in agreement with D docs, but I'm not sure this is what makes most sense. On Sun, Oct 20, 2013 at 6:49 PM, Timothee Cour wrote: > I was hoping std.path.globMatch distinguished single * (non-recursive) vs > double ** (recursive) > so that: > "a1/a2/a3.tx

globMatch: distinguish double ** (recursive) vs single *

2013-10-20 Thread Timothee Cour
I was hoping std.path.globMatch distinguished single * (non-recursive) vs double ** (recursive) so that: "a1/a2/a3.txt".globMatch("*/a3.txt") returns false "a1/a2/a3.txt".globMatch("**/a3.txt") returns true as in good shells (and python 3.4 IRRC) but it's not the case. Is that intended?

Re: Syntax for heap allocated void initialized arrays

2013-10-15 Thread Timothee Cour
On Sat, Sep 21, 2013 at 7:23 AM, bearophile wrote: > simendsjo: > > > I'm setting every element in the array, and every field of the >> element, so I should be safe, right? >> > > I think that's sufficiently safe. If the GC run before you have > initialized those fields, and some of those fields

how to get a (ref) tuple from a static array ?

2013-10-15 Thread Timothee Cour
how to write a expand function that satisfies the following? void fun(ref int a,ref int b){ a=1; } void main(){ int[2]c; fun(c.expand); assert(c[0]==1); }

Re: how to pass multiple arguments via a mixin

2013-10-15 Thread Timothee Cour
because there could be a mix of the two On Tue, Oct 15, 2013 at 5:56 PM, Dicebot wrote: > On Wednesday, 16 October 2013 at 00:36:46 UTC, Timothee Cour wrote: > >> ... >> > > Have you tried run-time tuple? > > ``` > import std.typecons; > writeln(mixin("tuple(&a,&b).**expand")); > ``` >

how to pass multiple arguments via a mixin

2013-10-15 Thread Timothee Cour
is there a general solution to pass multiple arguments to a function via a mixin? see below for a partial solution using Alias, which fails for the last case below: void main(){ import std.stdio; string a="A"; string b="B"; writeln(a,b);// OK (prints "AB") writeln(&a,&b);//OK (prints bo

how to handle memory ownership when interfacing with C/C++ via internal pointers

2013-10-10 Thread Timothee Cour
Short version: I have a struct A* aptr allocated in C/C++ with an internal pointer aptr->ptr (say a double*) I want to store a reference x (say double[]) in D to aptr only through aptr->ptr, not through aptr directly as it's inconvenient in my use case. How do I achieve that, so that when x goes o

backtrace_symbols should be called only when exception thrown

2013-09-22 Thread Timothee Cour
in src/druntime/src/core/runtime.d, backtrace_symbols is called in DefaultTraceInfo constructor. Shouldn't it be called only when exception is thrown, to speed up the case when the exception is not thrown?

dmd segfaults on nested template instantiation (eg A!(A!(int)) )

2013-09-18 Thread Timothee Cour
I just filed a bug report ( http://d.puremagic.com/issues/show_bug.cgi?id=11067) Is there a workaround that keeps same syntax for user code? Use case: i'm generating those from swig(+modifications to map C++ templates to D templates) so I can't factor the template bodies for different template ins

this(T...) not called in struct constructor

2013-09-17 Thread Timothee Cour
This may have been discussed before, but I'm not sure whether this is a bug or not. In any case it's a bit confusing. struct Foo2{ this(T...)(T args){ assert(0); } } void main(){ auto a2=Foo2();//doesn't call assert(0) (ie this(T...) not called) }

Re: nothrow function to tell if a string can be converted to a number?

2013-09-11 Thread Timothee Cour
anyways, isNumeric sounds buggy, isn't it? On Wed, Sep 11, 2013 at 4:03 PM, H. S. Teoh wrote: > On Wed, Sep 11, 2013 at 02:10:32PM -0700, Timothee Cour wrote: > > actually that doesn't work: > > > > assert(!isNumeric(`j`)); //ok > > assert(!isNumeric(`i`))

Re: nothrow function to tell if a string can be converted to a number?

2013-09-11 Thread Timothee Cour
auto x=parse!T(s); return s.length==0; } I'd like to get a version that never throws. On Fri, Sep 6, 2013 at 9:38 PM, Jonathan M Davis wrote: > On Friday, September 06, 2013 21:15:44 Timothee Cour wrote: > > I'd like to have a function: > > > > @nothrow bool isN

Re: nothrow function to tell if a string can be converted to a number?

2013-09-08 Thread Timothee Cour
ration to escapeString unittest{ assert(`"abc"`. unEscapeString ==`abc`); } I several use cases for those, which I can explain if it's unclear. On Sun, Sep 8, 2013 at 8:16 PM, Timothee Cour wrote: > > > > On Fri, Sep 6, 2013 at 9:38 PM, Jonathan M Dav

Re: nothrow function to tell if a string can be converted to a number?

2013-09-08 Thread Timothee Cour
On Fri, Sep 6, 2013 at 9:38 PM, Jonathan M Davis wrote: > On Friday, September 06, 2013 21:15:44 Timothee Cour wrote: > > I'd like to have a function: > > > > @nothrow bool isNumberLitteral(string a); > > unittest{ > > assert(isNumberLitteral("

nothrow function to tell if a string can be converted to a number?

2013-09-06 Thread Timothee Cour
I'd like to have a function: @nothrow bool isNumberLitteral(string a); unittest{ assert(isNumberLitteral("1.2")); assert(!isNumberLitteral("a1.2")); assert(!isNumberLitteral("a.b")); } I want it nothrow for efficiency (I'm using it intensively), and try/catch as below has significant runtim

dmd: how to pass several linker options with just one -L? (or feature request)

2013-09-06 Thread Timothee Cour
is there a way to achieve this: dmd -L-lfoo -L-lbar main.d with a single call to -L to pass several linker options; something like: dmd -L'-lfoo -lbar' main.d except that won't work due to '' being treated as one argument. Maybe something like: dmd --L=' flag1 flag2' main.d which would treat the ar

Re: is the tools part of the test suite? currently tools/ddemangle doesn't compile on git master

2013-08-24 Thread Timothee Cour
nger wrote: > > On Saturday, 24 August 2013 at 03:20:42 UTC, Timothee Cour wrote: > > >More often than not, the tools submodule ( > > >https://github.com/D-Programming-Language/tools) will not build on > > >git > > >master. So I'm wondering whether it'

alias this bug?

2013-08-24 Thread Timothee Cour
is this a bug? the call to join invalidates the "name" field of A: import std.array; import std.stdio; class A{ string name; this(string name){this.name=name;} alias name this; ~this(){ writeln("deleting"); } } void main(){ auto a=[new A(`foo`)]; assert(a[0].length); wri

Re: is the tools part of the test suite? currently tools/ddemangle doesn't compile on git master

2013-08-23 Thread Timothee Cour
H. S. Teoh wrote: > On Fri, Aug 23, 2013 at 08:20:29PM -0700, Timothee Cour wrote: > > More often than not, the tools submodule ( > > https://github.com/D-Programming-Language/tools) will not build on git > > master. So I'm wondering whether it's even being tested befo

is the tools part of the test suite? currently tools/ddemangle doesn't compile on git master

2013-08-23 Thread Timothee Cour
More often than not, the tools submodule ( https://github.com/D-Programming-Language/tools) will not build on git master. So I'm wondering whether it's even being tested before pushing commits. The error I have now is with ddemangle: std.md5 is scheduled for deprecation. Please use std.digest.md

Re: cannot build LDC on OSX

2013-08-18 Thread Timothee Cour
ok i updated the issue on the git hub link i posted On Sun, Aug 18, 2013 at 7:43 PM, Tyler Jameson Little wrote: > On Sunday, 18 August 2013 at 23:31:58 UTC, Timothee Cour wrote: > >> I'm bumping up this issue here >> https://github.com/ldc-**developers/ldc/issues/436

Re: scoped imports

2013-08-18 Thread Timothee Cour
On Sun, Aug 18, 2013 at 7:52 AM, Joseph Rushton Wakeling < joseph.wakel...@webdrake.net> wrote: > On Sunday, 18 August 2013 at 09:52:29 UTC, Timothee Cour wrote: > >> On Sun, Aug 18, 2013 at 2:31 AM, Joseph Rushton Wakeling < >> joseph.wakel...@webdrake.net> wrot

cannot build LDC on OSX

2013-08-18 Thread Timothee Cour
I'm bumping up this issue here https://github.com/ldc-developers/ldc/issues/436 as it's been 16 days with no answer ... am i doing something wrong? it used to work a while ago, IIRC.

Re: scoped imports

2013-08-18 Thread Timothee Cour
On Sun, Aug 18, 2013 at 2:31 AM, Joseph Rushton Wakeling < joseph.wakel...@webdrake.net> wrote: > On Sunday, 18 August 2013 at 01:33:51 UTC, Timothee Cour wrote: > >> that's not DRY: in my use case, a group of functions use certain imports, >> it would be annoying a

Re: how do I get the ith field of a std.typecons.Tuple ?

2013-08-18 Thread Timothee Cour
ields!T==["foo","bar"]); } On Sun, Aug 18, 2013 at 2:26 AM, Timothee Cour wrote: > > > > On Sun, Aug 18, 2013 at 2:15 AM, John Colvin < > john.loughran.col...@gmail.com> wrote: > >> On Sunday, 18 August 2013 at 08:46:17 UTC, Timothee Cour wrote: >>

Re: how do I get the ith field of a std.typecons.Tuple ?

2013-08-18 Thread Timothee Cour
On Sun, Aug 18, 2013 at 2:15 AM, John Colvin wrote: > On Sunday, 18 August 2013 at 08:46:17 UTC, Timothee Cour wrote: > >> A) >> how do I get the ith field of a std.typecons.Tuple ? >> ideally, it should be as simple as: >> >> auto t=Tuple!(int,"nam

how do I get the ith field of a std.typecons.Tuple ?

2013-08-18 Thread Timothee Cour
A) how do I get the ith field of a std.typecons.Tuple ? ideally, it should be as simple as: auto t=Tuple!(int,"name",double,"name2")(1); static assert(t.fields[0] == "name"); It seems the necessary items are private, so how do I get the ith field of a std.typecons.Tuple ? I really don't want to p

how to get enclosing function as symbol ? (eg: __function__.stringof ==__FUNCTION__)

2013-08-17 Thread Timothee Cour
Is there any way to get the enclosing function as symbol ? I'd like something like that: alternative names would be: __function__ __context__ auto fun(alias caller=__function__)(){ //caller represents fun1!double return ReturnType!caller.init; } T fun1(T)(T x){ assert(__function__.str

Re: scoped imports

2013-08-17 Thread Timothee Cour
n Wakeling < joseph.wakel...@webdrake.net> wrote: > On Saturday, 17 August 2013 at 22:30:14 UTC, Timothee Cour wrote: > >> Is there a way to achieve this: >> >> >> module foo; >> >> { >> import bar; >> void fun1(){bar.barfun();} >> void

Re: scoped imports

2013-08-17 Thread Timothee Cour
On Sat, Aug 17, 2013 at 3:36 PM, H. S. Teoh wrote: > On Sat, Aug 17, 2013 at 03:29:56PM -0700, Timothee Cour wrote: > [...] > > Related question: > > > > Why isn't the following allowed: > > > > void fun(){ > > // code without versio

Re: how to get (absolute) file path from ModuleInfo? how to get include search path?

2013-08-17 Thread Timothee Cour
Additionally, is there a way to get: * the absolute path of __FILE__ at the time the file was compiled (the compiler knows it) * the current directory in which the compiler compiled that file On Sat, Aug 17, 2013 at 1:26 PM, Timothee Cour wrote: > I'd like to redefine 'vo

Re: scoped imports

2013-08-17 Thread Timothee Cour
thanks. That's a bit clunky though, so it's unlikely to be used. Not sure what it would take to make the grammar allow it. On Sat, Aug 17, 2013 at 4:23 PM, bearophile wrote: > Timothee Cour: > > > Is there a way to achieve this: >> >> >> module

Re: scoped imports

2013-08-17 Thread Timothee Cour
On Sat, Aug 17, 2013 at 4:24 PM, bearophile wrote: > H. S. Teoh: > > Most of your answer posts break threads. I suggest you to try to find ways > to avoid that. > This issue keeps reappearing and people keep complaining; it's not his fault, the problem is with the forum.dlang.org and that should

scoped imports

2013-08-17 Thread Timothee Cour
Is there a way to achieve this: module foo; { import bar; void fun1(){bar.barfun();} void fun2(bar.BarType a){} } // now bar is not in scope anymore. void fun3(){} This would reduce name clashes conflicts, ease refactorings and in general make code a bit cleaner. Related question: W

how to get (absolute) file path from ModuleInfo? how to get include search path?

2013-08-17 Thread Timothee Cour
I'd like to redefine 'void _d_assertm(ModuleInfo* m, uint line){...}' to print more informative message with full path to module; right now m.name just shows module name. Is the only way to manually search through include paths until it is found ? That seems silly because the compiler knows it alr

Re: why doesn't formattedRead take args by ref instead of by pointer?

2013-08-17 Thread Timothee Cour
ot;%s %s",&a,&b); assert(a=="a1" && b=="a2 a3"); On Mon, May 20, 2013 at 10:44 PM, Dmitry Olshansky wrote: > 21-May-2013 01:39, Timothee Cour пишет: > > That was indeed what I was using in my updated ref based >> reimplementation

html documentation should show public imports

2013-07-17 Thread Timothee Cour
std.range contains public import std.array. There are a few full module public imports like that in phobos. What's the rationale? I understand for hierarchical modules (breaking modules into packages) but for this? it's a bit confusing, as searching for 'array' in std.range docs yields nothing. My

Re: Template explosion

2013-07-16 Thread Timothee Cour
On Tue, Jul 16, 2013 at 8:29 PM, Timothee Cour wrote: > On Tue, Jul 16, 2013 at 7:52 PM, JS wrote: > >> >> It seems that one must use two templates to process built in times and >> strings >> >> template A(string a) { ... } >> template A(a) { enum A = A(

Re: Template explosion

2013-07-16 Thread Timothee Cour
On Tue, Jul 16, 2013 at 7:52 PM, JS wrote: > > It seems that one must use two templates to process built in times and > strings > > template A(string a) { ... } > template A(a) { enum A = A(typeof(a).stringof); } > > This is so we can do stuff like A!(double) and A!("double"). > > The problem is

Re: interacting with a process with redirected stdin/stdout/stderr

2013-07-16 Thread Timothee Cour
On Tue, Jul 16, 2013 at 10:01 AM, Anthony Goins wrote: > On Monday, 15 July 2013 at 06:46:52 UTC, timotheecour wrote: > >> On Monday, 15 July 2013 at 03:49:10 UTC, Timothee Cour wrote: >> >>> I'm trying to interact with a process using std.process and >>>

Re: Naming convention for template parameters

2013-07-15 Thread Timothee Cour
On Mon, Jul 15, 2013 at 4:02 PM, H. S. Teoh wrote: > On Tue, Jul 16, 2013 at 12:52:21AM +0200, Joseph Rushton Wakeling wrote: > > Hello all, > > > > Quick query -- what's the preferred template variable name for a range > type? > > > > I've seen both R and Range used as options but want to confir

interacting with a process with redirected stdin/stdout/stderr

2013-07-14 Thread Timothee Cour
I'm trying to interact with a process using std.process and redirected stdin/stdout/stderr. What would be the recommended way? For example: auto pipes=pipeShell("myprocess",Redirect.all); while(true){ pipes.stdin.rawWrite(some_command); foreach (line; pipes.stdout.byLine) { //do somet

how to profile compilation steps?

2013-07-11 Thread Timothee Cour
I'd like to at least get timestamps for the various steps appearing the the dmd -v output. Is there an easy way to modify dmd to output that? That could be fed to a D function that parses it and generates a nice profile report (ie the compiler would do not much more than just adding timestamps, lea

Re: Tuple indexing and slicing

2013-07-11 Thread Timothee Cour
On Thu, Jul 11, 2013 at 1:05 AM, Simen Kjaeraas wrote: > On 2013-07-11, 00:52, Timothee Cour wrote: > > Why not support Tuple indexing and slicing with [] syntax? >> (see below for a way to index/slice a tuple) >> >> void main(){ >> alias T=Tuple!(int,doubl

Re: Tuple indexing and slicing

2013-07-10 Thread Timothee Cour
On Wed, Jul 10, 2013 at 6:16 PM, Jonathan M Davis wrote: > On Wednesday, July 10, 2013 18:10:42 Timothee Cour wrote: > > On Wed, Jul 10, 2013 at 5:49 PM, Artur Skawina > wrote: > > > On 07/11/13 00:52, Timothee Cour wrote: > > > > Why not support Tuple in

Re: Tuple indexing and slicing

2013-07-10 Thread Timothee Cour
On Wed, Jul 10, 2013 at 5:49 PM, Artur Skawina wrote: > On 07/11/13 00:52, Timothee Cour wrote: > > Why not support Tuple indexing and slicing with [] syntax? > > (see below for a way to index/slice a tuple) > > Not sure I understand the question. > I guess you'

Tuple indexing and slicing

2013-07-10 Thread Timothee Cour
Why not support Tuple indexing and slicing with [] syntax? (see below for a way to index/slice a tuple) void main(){ alias T=Tuple!(int,double); pragma(msg,T[0].stringof);//_expand_field_0 //pragma(msg,T[0..2].stringof); //Error: cannot slice type 'Tuple!(int, double) pragma(msg,typeof(T.

Re: inverse of std.demangle?

2013-07-10 Thread Timothee Cour
On Wed, Jul 10, 2013 at 11:39 AM, Adam D. Ruppe wrote: > On Wednesday, 10 July 2013 at 17:44:51 UTC, Timothee Cour wrote: > >> * One use case is using it in shared libraries: >> user asks for a symbol via its demangled string representation (which is >> most natural for u

Re: Managing implementation details...

2013-07-10 Thread Timothee Cour
On Mon, Jul 8, 2013 at 2:00 AM, bearophile wrote: > JS: > > > I think when the code is compiled a "report" can be generated listing the >> priorities along with the locations in the file would be beneficial... >> > > It looks like a useful thing, on the other hand I think most people solve > thi

Re: C standard libraries

2013-07-10 Thread Timothee Cour
On Tue, Jul 2, 2013 at 5:52 AM, bearophile wrote: > Adam D. Ruppe: > > > The older std.c is kept around just for compatibility with the old names >> before the move, at least as far as I know. Maybe they haven't fully >> deprecated it though because there's other reasons I don't know about, >> s

Re: inverse of std.demangle?

2013-07-10 Thread Timothee Cour
On Wed, Jul 10, 2013 at 10:30 AM, Adam D. Ruppe wrote: > On Wednesday, 10 July 2013 at 16:30:25 UTC, Timothee Cour wrote: > >> Do you have a pointer for that function in dmd ? >> > > The compiler doesn't do it as one function, I mean it can parse as string >

Re: inverse of std.demangle?

2013-07-10 Thread Timothee Cour
orth doing. On Wed, Jul 10, 2013 at 10:30 AM, Adam D. Ruppe wrote: > On Wednesday, 10 July 2013 at 16:30:25 UTC, Timothee Cour wrote: > >> Do you have a pointer for that function in dmd ? >> > > The compiler doesn't do it as one function, I mean it can parse as s

Re: inverse of std.demangle?

2013-07-10 Thread Timothee Cour
On Wed, Jul 10, 2013 at 9:11 AM, Adam D. Ruppe wrote: > As far as I know, no such function exists (outside of dmd itself). > Do you have a pointer for that function in dmd ? Again, I'm not talking about symbol => mangled string but about demangled string=> mangled string

Re: inverse of std.demangle?

2013-07-10 Thread Timothee Cour
ping? On Wed, Jul 3, 2013 at 5:42 PM, Timothee Cour wrote: > I'd like to have a function: > string mangle(string mangled_string); > unittest{ > void foo(int x){} > assert(foo.mangleof.demangle.mangle == foo.mangleof); > } > > is there such a functionality, even partially? > > >

function type stringification

2013-07-08 Thread Timothee Cour
I'm a bit confused with the behavior of function type stringification: int main(string[]args){ auto foo=&main; pragma(msg,typeid(typeof(foo))); pragma(msg,typeid(typeof(foo)).stringof); //pragma(msg,typeid(typeof(foo))); import std.stdio; writeln(typeid(typeof(foo)).stringof);

inverse of std.demangle?

2013-07-03 Thread Timothee Cour
I'd like to have a function: string mangle(string mangled_string); unittest{ void foo(int x){} assert(foo.mangleof.demangle.mangle == foo.mangleof); } is there such a functionality, even partially?

Re: typeof map

2013-06-24 Thread Timothee Cour
I think it's because each lambda litteral is treated unique. can dmd be changed to recognize identical lambda litterals as identical? Is there any particular issue making that difficult? it already recognizes identical string literals as identical On Mon, Jun 24, 2013 at 7:45 PM, cal wrote: > Is

Re: alias c=mixin(expr); disallowed, why?

2013-06-22 Thread Timothee Cour
On Sat, Jun 22, 2013 at 2:55 PM, Timon Gehr wrote: > On 06/22/2013 11:51 PM, Timothee Cour wrote: > >> >> >> On Sat, Jun 22, 2013 at 2:47 PM, Timon Gehr > <mailto:timon.g...@gmx.ch>> wrote: >> >> On 06/22/2013 09:52 PM, Timothee Cour wrote: &

Re: alias c=mixin(expr); disallowed, why?

2013-06-22 Thread Timothee Cour
On Sat, Jun 22, 2013 at 2:47 PM, Timon Gehr wrote: > On 06/22/2013 09:52 PM, Timothee Cour wrote: > >> Is there a reason the language spec disallows this? >> >> >> void main(){ >> auto a=mixin("1");//OK >> alias b=a;//OK >&g

alias c=mixin(expr); disallowed, why?

2013-06-22 Thread Timothee Cour
Is there a reason the language spec disallows this? void main(){ auto a=mixin("1");//OK alias b=a;//OK mixin("alias c=a;");//OK // alias c=mixin("a");//NG : Error: basic type expected, not mixin }

phabricator : code review, bug tracking etc

2013-06-21 Thread Timothee Cour
phabricator looks pretty decent for code review, bug tracking etc. It was created at facebook and is used by many other companies; it's actively maintained and developed. It could be a good replacement for bugzilla and other components.

Re: assert(false)

2013-06-20 Thread Timothee Cour
A) does assert(foo) where foo is an expression that cat be evaluated at compile time (eg via CTFE etc) behave same as assert(true)/assert(false)? B) It is usually "bad practice" to keep an assert in release > ("assert(false)"), because the code should already have been checked, and > you shouldn

Re: std.process: how to process stdout chunk by chunk without waiting for process termination

2013-06-19 Thread Timothee Cour
On Tue, Jun 18, 2013 at 3:00 PM, Steven Schveighoffer wrote: > On Tue, 18 Jun 2013 17:41:57 -0400, Timothee Cour < > thelastmamm...@gmail.com> wrote: > > I'd like to do the following: >> >> auto pipes = pipeShell(command, Redirect.stdout | Redirect.stderr

std.process: how to process stdout chunk by chunk without waiting for process termination

2013-06-18 Thread Timothee Cour
I'd like to do the following: auto pipes = pipeShell(command, Redirect.stdout | Redirect.stderr); while(true){ version(A1) string line=pipes.stdout.readln; version(A2) auto line=pipes.stdout.readChunk(10); version(A3) auto line=pipes.stdout.readChar(); // do something with line if(try

Re: can we detect at compile time module ctor/dtor cycles ?

2013-06-18 Thread Timothee Cour
On Tue, Jun 18, 2013 at 6:01 AM, Steven Schveighoffer wrote: > On Mon, 17 Jun 2013 21:19:57 -0400, Timothee Cour < > thelastmamm...@gmail.com> wrote: > > I understand your point, however I argued above that we should run a test >> at compile time to detect cycles. I

Re: can we detect at compile time module ctor/dtor cycles ?

2013-06-17 Thread Timothee Cour
On Mon, Jun 17, 2013 at 5:11 PM, bearophile wrote: > Andrej Mitrovic: > > > No idea, but I've wondered this myself too. After all "imports" are a >> static feature and all are known at compile-time. >> > > rdmd is used often in a situation where it knows all the modules of a > program. So it must

Re: can we detect at compile time module ctor/dtor cycles ?

2013-06-17 Thread Timothee Cour
On Mon, Jun 10, 2013 at 10:20 AM, Steven Schveighoffer wrote: > On Sun, 09 Jun 2013 23:15:42 -0400, Timothee Cour < > thelastmamm...@gmail.com> wrote: > > On Fri, Jun 7, 2013 at 11:41 PM, Jonathan M Davis > >wrote: >> >> On Friday, June 07, 2013 23:23:25 Tim

make Pid constructor public

2013-06-17 Thread Timothee Cour
inside std.process it says: // Pids are only meant to be constructed inside this module, so we make the constructor private. However, this makes a number of useful functions from std.process useless unless the processes were created via one of std.process' functions. Can we make std.process.Pid.thi

Re: Nesting Variants

2013-06-13 Thread Timothee Cour
On Sun, May 19, 2013 at 4:31 PM, Wyatt wrote: > I'm trying to use Variants and ran into the following sort of situation: > > //Using DMD 2.062 > import std.stdio; > import std.variant; > > void main(){ > int key = 1; > Variant[] one; > Variant[] ender; > one = new

Re: Why there is too many uneccessary casts?

2013-06-11 Thread Timothee Cour
On Tue, Jun 11, 2013 at 11:26 AM, H. S. Teoh wrote: > On Tue, Jun 11, 2013 at 01:25:24PM -0400, Steven Schveighoffer wrote: > > On Tue, 11 Jun 2013 12:18:52 -0400, Adam D. Ruppe > > wrote: > > > > >On Tuesday, 11 June 2013 at 16:05:30 UTC, Steven Schveighoffer wrote: > > >>CPU performs math at i

Re: can we detect at compile time module ctor/dtor cycles ?

2013-06-09 Thread Timothee Cour
On Fri, Jun 7, 2013 at 11:41 PM, Jonathan M Davis wrote: > On Friday, June 07, 2013 23:23:25 Timothee Cour wrote: > > Why can't we detect at compile time module ctor/dtor cycles (instead of > > runtime) ? > > At minimum, separate compilation stops it. A .di file isn'

best way to handle UFCS with ambiguous names: using std.typetuple.Alias!

2013-06-09 Thread Timothee Cour
UFCS chains are problematic when a symbol is ambiguous (eg after import std.stdio:write;import std.file:write); I previously suggested to add the syntax 'arg1.(std.file.write)(arg2)' (see 'support UFCS with fully qualified function names (was in "digitalmars.D.learn")' to avoid breaking UFCS chai

can we detect at compile time module ctor/dtor cycles ?

2013-06-07 Thread Timothee Cour
Why can't we detect at compile time module ctor/dtor cycles (instead of runtime) ? See example below. It should be easy to detect the chain at CT: algo: build graph from import dependencies a=>b if module a imports module b. mark as red the modules that have a ctor collapse each non-red node into

Re: geting stack trace from signal handlers

2013-06-07 Thread Timothee Cour
On Fri, Jun 7, 2013 at 12:39 AM, nazriel wrote: > On Thursday, 6 June 2013 at 21:50:58 UTC, Timothee Cour wrote: > >> Great! >> two issues (on OSX at least): >> >> A) >> it seems the top-most element of the call stack gets chopped off; eg in >> your

Re: geting stack trace from signal handlers

2013-06-06 Thread Timothee Cour
0x000102e4c18d D2rt6dmain211_d_run_mainUiPPaPUAAaZiZi7runMainMFZv + 33 iterm#2 is unreadable. On Thu, Jun 6, 2013 at 2:50 PM, Timothee Cour wrote: > Great! > two issues (on OSX at least): > > A) > it seems the top-most element of the call stack gets chopped off; eg in &

Re: geting stack trace from signal handlers

2013-06-06 Thread Timothee Cour
iel wrote: > On Wednesday, 5 June 2013 at 21:05:53 UTC, Timothee Cour wrote: > >> how do i get a stacktrace inside handleTermination? >> >> If not currently possible, could we have a compile flag that would enable >> this kind of feature? (making code slower would be

geting stack trace from signal handlers

2013-06-05 Thread Timothee Cour
how do i get a stacktrace inside handleTermination? If not currently possible, could we have a compile flag that would enable this kind of feature? (making code slower would be OK, its an opt in feature) Ideally we'd also be able to walk up or down the stack trace (kind of what gdb would do, but I

Re: Is the -property compiler flag broken/bad idea?

2013-06-05 Thread Timothee Cour
I had a better proposal: http://forum.dlang.org/thread/rftboygivwmwizeyw...@forum.dlang.org optional parens everywhere except last position of function chain. This makes it visually unambiguous what is a function vs function call and avoids all but last parens, makes @property/(-property) obsolet

Re: version(noboundscheck) + friends

2013-06-04 Thread Timothee Cour
e for everyone in bug chasing mode On Tue, Jun 4, 2013 at 12:40 AM, Jonathan M Davis wrote: > On Tuesday, June 04, 2013 00:38:17 Timothee Cour wrote: > > > given the overhead that it would introduce > > > > Do you mean compiler-implementation overhead or resulting runtim

<    1   2   3   >