On Friday, 13 February 2015 at 19:03:10 UTC, Jonathan Marler
wrote:
This question comes from wanting to be able to throw an
exception in code that is @nogc.
https://dlang.org/changelog/2.079.0.html#dip1008
```d
void main() @nogc
{
throw new Exception("I'm @nogc now");
}
```
On Friday, 12 January 2018 at 18:51:31 UTC, Basile B. wrote:
On Friday, 12 January 2018 at 18:50:10 UTC, Basile B. wrote:
On Friday, 12 January 2018 at 17:58:30 UTC, Stefan Koch wrote:
On Friday, 12 January 2018 at 14:13:22 UTC, Basile B. wrote:
I have a simple program that only compiles if the
On Friday, 26 January 2018 at 11:18:21 UTC, Oleksii Skidan wrote:
Hi,
I wonder if it's possible to convert D language code into a
string at compile time? C/C++ preprocessor has this feature
built-in: `#` preprocessing operator allows converting a macro
argument into a string constant. See the
On Saturday, 30 January 2016 at 03:13:59 UTC, Matt Elkins wrote:
std.typecons.Unique seems to require heap allocation, which
makes it a far cry from std::unique_ptr.
isn't unique_ptr typically for heap allocation?
eg:
https://stackoverflow.com/questions/42910711/unique-ptr-heap-and-stack-allo
On Wednesday, 13 December 2017 at 00:43:31 UTC, rikki cattermole
wrote:
You don't need to change this and if you think you do, you're
wrong :)
Except when you need to:
https://github.com/dlang/dub/issues/1305
dub build --compiler=ldmd2 overwrites files in ~/.dub written by
dub build #1305
Might I suggest that you simply define an enum for UnixEpoch
that's a
SysTime. Then you can do whatever you want.
ping on this.
On Saturday, 10 December 2016 at 02:39:33 UTC, timotheecour wrote:
Have a look at what `trace -E d_executable args` and `trace -E
c++_executable args`
print on startup and grep for dlopen calls and the like.
do you mean strace?
I have trace on OSX but I'm asking for linux.
Looking a
Have a look at what `trace -E d_executable args` and `trace -E
c++_executable args`
print on startup and grep for dlopen calls and the like.
do you mean strace?
I have trace on OSX but I'm asking for linux.
UPDATE:
* b Loader.d:123 didn't help either:
error: parsing line table prologue at 0x (parsing ended
around 0x
Breakpoint 1: where =
mybinary.temp`D4gtkc6Loader6Linker12_staticDtor3FZv, address =
0x000100315410
(process exited despite breakpoint); dmd's dwarf debug info se
On Thursday, 21 May 2015 at 19:06:35 UTC, Jacob Carlborg wrote:
On 2015-05-21 11:06, Timothee Cour via Digitalmars-d-learn
wrote:
Can I create an instance of A without calling a constructor?
(see below)
Use case: for generic deserialiaztion, when the
deserialization library
encounters a class w
On Saturday, 23 May 2015 at 08:01:28 UTC, timotheecour wrote:
On Saturday, 10 November 2012 at 22:09:07 UTC, Andrej Mitrovic
wrote:
On 11/10/12, nixda wrote:
You can try vibe.d bson serialization.
http://vibed.org/api/vibe.data.bson/serializeToBson
It doesn't handle them either. Anyway
On Saturday, 10 November 2012 at 22:09:07 UTC, Andrej Mitrovic
wrote:
On 11/10/12, nixda wrote:
You can try vibe.d bson serialization.
http://vibed.org/api/vibe.data.bson/serializeToBson
It doesn't handle them either. Anyway I've implemented it for
msgpack
(took a whole of 30 minutes, it's a
On Wednesday, 6 August 2014 at 17:03:23 UTC, Timothee Cour via
Digitalmars-d-learn wrote:
Is there a reason why 'with(Foo):' is not allowed, and we have
to
use with(Foo){...} ?
It would be more in line with how other scope definitions work
(extern(C)
etc)
ping, anyone?
On Thursday, 5 June 2014 at 06:58:50 UTC, Timothee Cour via
Digitalmars-d-learn wrote:
Is there a way to do this?
import std.algorithm;
auto fun(T)(T a){return a;}
template fun2(T){auto fun2(T a){return fun(a);}}//OK but heavy
syntax and
cannot be nested inside test()
void main(){
//alias
On Thursday, 13 February 2014 at 23:56:35 UTC, Timothee Cour
wrote:
how to iterate over an AA by key-value pair (tuple)?
use case:
avoid interrupting UFCS chains, eg:
foo.generate_aa.byKeyValue.filter!(a=>a[0].isLower).map!(a=>a[1])
...
of course I could roll my own function but I was wondering
On Thursday, 10 October 2013 at 23:02:29 UTC, Timothee Cour wrote:
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 inco
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
redirected stdin/stdout/stderr.
What would be the recommended way?
For example:
auto pipes=pipeShell("myprocess",Redirect.all);
while(true){
pipes.stdin.rawWrite(some_
On Monday, 10 June 2013 at 08:13:42 UTC, John Colvin wrote:
On Monday, 10 June 2013 at 02:02:09 UTC, Timothee Cour wrote:
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.wri
something like this, which we should have in std.regex:
string escapeRegex(string a){
import std.string;
enum transTable = ['[' : `\[`, '|' : `\|`, '*': `\*`, '+': `\+`,
'?': `\?`, '(': `\(`, ')': `\)`];
return translate(a, transTable);
}
string escapeRegexReplace(string a){
See below:
import std.stdio;
import std.regex;
void main(){
"h(i".replace!(a=>a.hit~a.hit)(regex(`h\(`,"g")).writeln; //this
works, but I need to specify the escape manually
// "h(i".replace!(a=>a.hit~a.hit)(regex(`h(`,"gl")).writeln;
//I'd like this to work with a flag, say 'l' (lowercase L
On Sunday, 19 May 2013 at 14:33:32 UTC, Ali Çehreli wrote:
On 05/19/2013 05:34 AM, Simen Kjaeraas wrote:
Well, there is also opDot:
What is the state of opDot? According to the change log, it has
been introduced as a part of "Version D 2.013 Apr 22, 2008"
with the note "Added opDot, which is
IMO, there's too little value in those ufcsWritef, ufcsWritefln,
ufcsWriteln, ufcsWritefln to justify adding them. When does it
stop??
Why not introduce 'tap', which is more generic and has been
proposed before:
something like this:
T tap(alias fun,T)(T a){
fun(a);
return a;
}
Then:
aut
void main(){
import std.demangle;
import std.stdio;
writeln(demangle("_D5tango4text7convert6Format12__ModuleInfoZ"));
//_D5tango4text7convert6Format12__ModuleInfoZ
writeln(demangle("_D5tango4text7Unicode6toFoldFAxaAaZAa"));
//char[] tango.text.Unicode.toFold(const(c
Can we replace phobos' and tools' Makefile with D with following
advantages:
* no more 3 distinct files (posix.mak,win32.mak,win64.mak),
instead use version() to maximize code reuse.
* less verbosity / bugs / forward compatibility issues eg when a
module is added/renamed: eg could take advan
That's opEquals' job. It deals with recursive comparisons like
you're describing here just fine.
Except the functionality is very different, as opEquals is blind
to range semantics. I want equalRecurse to work as follows:
struct A{ int[]b=[1]; }
void main(){
auto a1=A();
I think I understand what you are after and I like the idea.
I've got a few:
-typesDeepEqual
-typesDeepCmp
-deepHash
approxEqualRecurse could also be useful for numerical
applications (same as equalRecurse, except uses approxEqual for
floating point comparisons)
https://github.com/patefac
And how do you even have the concept of recursion without some
sort of range or container to recursively iterate through?
It's not hard: I've done it for a serialization library I've been
working on (which has some advantages over std.orange, such as
serializing to json/binary etc. more on thi
somewhere else, but I don't see a relevant package. Maybe a new
std.algorithm2 for non-ranges?
Also, the OT's firstDifference would go there too, and I have a
recursive (to specified level) toStringRecurse that would
belong there too.
Also, I'd add to that list copyRecurse and some more, tha
I think none of you got the point of equalRecurse, so let me
clarify.
equalRecurse should work on any type, not just inputRanges, see
my example in the OT with a struct containing an array: currently
std.algorithm.equal has isInputRange conditions on the arguments.
So, yes, it can go deep in
we need a std.algorithm.equalRecurse(T1,T2)(T1 a, T2 b) that
compares recursively a and b;
its behavior should be:
if opEqual is defined, call it
else, if its a range, call std.algorithm.equal (ie compare nb
elements, then each element for equality)
else, if it's a class/struct, make sure type
I forgot unittest:
unittest{
assert(uniqStable([1,3,1,0,2] ==[1, 3, 0, 2] ));
}
of course, it needs template on less, etc.
It's not an RDMD issue, it's Druntime. Specifically the baseName
function in src/rt/cover.d. This can easily be fixed.
Should I file a BUG/enhancement request?
The problem is Druntime can't have dependencies to Phobos.
Sure, I meant reusing same functionality (rewritten in C++) so
there's n
Why not have a -staticcov (or -ctcov) flag to dmd that produces
compile time code coverage?
This will work for most code (with the exception of virtual
methods called from a base class -- anything else?): it'll just
produce 1 or 0 depending for each line compiled in, depending on
whether it's r
rdmd -cov /Users/timothee/test/test_01.d
creates a file "-Users-timothee-test-test_01.lst"
A)
This leading "-" in filename is very unix unfriendly, eg:
mv "-Users-timothee-test-test_01.lst" temp.lst
yields: mv: illegal option --U, etc.
Even worse in the following case:
rdmd --force -cov -I.. ../
Is there any short term plan to make examples in ddoc runnable?
right now, the only one that runs is the one on the home page
dlang.org.
Example: in http://dlang.org/phobos/std_path.html:
the 1st code sample (under baseName)
when you click on run:
/home/c318/c110.d(2): Error: Declaration expec
On Saturday, 2 March 2013 at 18:42:13 UTC, Andrej Mitrovic wrote:
On 3/2/13, simendsjo wrote:
Which can you recommend?
I use ae's lite xml library:
https://github.com/CyberShadow/ae/blob/master/utils/xmllite.d
It's not a monster but thanks to UFCS I can easily extend it to
do
what I want.
One more: Did you try using std.container.Array?
Even if appender is more optimized than naked array appending,
it still has to work with the underlying system.
std.container.Array should be able to do just as well as
vector, or better (D move semnantics).
it's a bit better (see below for
Note that dynamic arrays are generic containers, so they aren't
exactly optimized for anything. You could try that test with
the "made for appending" std.array.appender: It always tries to
extend without reallocating, and only relocates when the
current memory segment is 100% full.
Furthermor
On Sunday, 3 February 2013 at 02:28:26 UTC, timotheecour wrote:
here goes:
http://d.puremagic.com/issues/show_bug.cgi?id=9444
please see my added comment in 9444 regarding capturing std err
instead of displaying it.
actually the new std.process pull request
(http://forum.dlang.org/thread
here goes:
http://d.puremagic.com/issues/show_bug.cgi?id=9444
please see my added comment in 9444 regarding capturing std err
instead of displaying it.
What's the rationale behind array appending adding a page size to
capacity instead of doubling, after the size of the array reaches
a certain size (cf what std::vector does) ? That seems like an
example of (evil?) early optimization.
T[]a;
int n=some big value;
foreach(i;0..n)
a~=T.in
The doc for std.process.shell says "If the process could not be
started or exits with an error code, throws an exception."
However on OSX I'm having a different kind of behavior.
Isn't there a unittest to test this?
---
import std.process;
import std.stdio;
void main(){
shell("asfasfas
correction regarding macros:
myheader.h:
#define MEX_INFORMATION_VERSION 1
interface file myheader.i:
%{
%include "myheader.h"
%}
%include myheader.h
generated d file will contain:
int MEX_INFORMATION_VERSION() @property {
auto ret = swig.mex_im.swig_mex_MEX_INFORMATION_VERSION_get();
retu
SWIG requires some kind of interface files, which I assume one
must have to manually write. Then what's the difference?
These can be as small as:
sfml.i:
%{
#include
%}
%include SFML/Config.hpp
%include SFML/Audio/Export.hpp
In practice, some additional tweaks may be needed to support
certa
Manually porting of C/C++ libraries shouldn't be the way to go (a
major problem being when said library gets updated, human errors,
porting to different architectures etc).
I've had good experience using SWIG to automate the job for me,
and used it successfully to port the following libraries to
It's a rather recent feature, there's probably a few bugs. Feel
free to file: http://d.puremagic.com/issues/
done:
http://d.puremagic.com/issues/show_bug.cgi?id=8856
does D fully support using import statements inside functions?
I sometimes get link errors eg:
void fun(){
import mypackage.mymodule;
mypackage.mymodule.myfun(); //will cause link error
}
if you haven't encountered it yet I can provide a simplified test
case.
I've filed the following bug: see Issue 8854
(http://d.puremagic.com/issues/show_bug.cgi?id=8854)
I'm curious as to what could cause such a bug, which disappears
when doing any of the following seemingly innocuous changes, such
as change a file name, change an import path, removing an
(unused)
On Thursday, 4 October 2012 at 19:20:54 UTC, Jacob Carlborg wrote:
On 2012-10-04 20:13, timotheecour wrote:
I'm fine with that (and already doing this, to call
Runtime.initialize),
but that doesn't solve the issue of this thread.
No, not if you need to redefine functions.
Even
If you're developing a library or similar you could have a
requirement that the user need to call "Library.initialize()"
before use. But of course, that's something anyone would like
to avoid.
I'm fine with that (and already doing this, to call
Runtime.initialize), but that doesn't solve the
Here, I want to redefine an extern(C) function, not call the
existing definition. I mentioned my previous post because I
realized that when adding (for example) assert(0) inside the
definition extern(C) std_stdio_static_this, it had no effect,
which led me to ask this more general question: how
What happens if you just call "std_stdio_static_this" the first
you do in your main function?
In my case I can't: I don't have control over the main function
(it could be written in C for example).
@property File stdin ()
{
if (!_stdin.p)
_stdin.p = &stdinImpl;
return _stdi
Module constructors if one of the things that don't work
properly. I don't know exactly how this works in std.stdio I
would need to study the code. If I recall correctly std.stdio
uses some kind of hack to avoid circular dependencies that can
otherwise occur if two modules, both having module
Thanks for the links. Ya, I did see those threads and I
understand there are limitations with dynamic load shared
libraries, however, your answer is not very helpful. We shouldn't
have to wait until they get 100% support to start using them (who
knows when that happens); some applications just
How do I call std_stdio_static_this() in std.stdio from a
dynamically loaded shared library (osx) ?
I need to do this in my scenario:
1) main program is launched
2) dynamic library is created
3) dynamic library is loaded and a function from it is called
4) everything works fine until a writeln(0
how to get version identifiers set during compilation?
ideally would be something like:
enum versions=VersionFlags;//returns ["OSX","debug"] for example
one use case is to have arbitrary logic on versions without
requiring new syntax.
eg:
static if(VersionFlags.canFind("OSX") &&
!VersionFlag
On Thursday, 20 September 2012 at 23:03:34 UTC, timotheecour
wrote:
inconsistent:
auto a1=tuple(tuple(1));//CT error
auto a2=tuple(tuple(1),1);//works
bug?
I filed it here:
http://d.puremagic.com/issues/show_bug.cgi?id=8702
inconsistent:
auto a1=tuple(tuple(1));//CT error
auto a2=tuple(tuple(1),1);//works
bug?
The code below fails to compile with:
Error: function
main.fun!(cast(ModeScore)0,int).fun.map!(__lambda33).map!(int[]).map
is a nested function and cannot be accessed from
main.fun!(cast(ModeScore)1,int).fun
which is weird.
But then comment out line B or line A (see below) and it works,
whi
done: http://d.puremagic.com/issues/show_bug.cgi?id=8674
If this behavior is not a bug, I wonder what's the rationale, but
also, how can we have such a "make" function that doesn't mess up
the template class name depending on the order of which is used
first (the make!T variant or the new A!T) ?
I filed 2 bugs:
http://d.puremagic.com/issues/show_bug.cgi?id=8653 cannot take
address of auto-return function declared in outside module:
"Error: forward reference"
http://d.puremagic.com/issues/show_bug.cgi?id=8654 cannot take
address of function which is 1)overloaded, 2) templated, and 3
On Friday, 14 September 2012 at 00:31:15 UTC, Andrej Mitrovic
wrote:
On 9/14/12, timotheecour wrote:
It has issues when the class is defined in a different modules,
but not always!
This looks like a compiler bug. Feel free to file it in
http://d.puremagic.com/issues/
I will.
here'
Why not pass it as a runtime argument?
void run(Fun, T...)(Fun fun, T args)
Yes I actually ended up doing that however the behavior seems
very buggy / unpredictable.
It has issues when the class is defined in a different modules,
but not always!
Here's a very weird example:
file main.d:
-
As part of a larger system (which converts function parameters to
a suitable type), I need to solve the following: pass a member
function to a "run" template function, access its
ParameterTypeTuple, and actually be able to run the function.
I've simplified the problem (see below). Is there a wa
Also, now that I think about it, why couldn't you do this?
(it's equivalent):
auto serialize(T)(T a) {
auto c = cast(SerializerBase) new Serializer!T;
return c.serialize(a);
}
that won't work with my example:
class A{}
class B:A{int x;}
A a=new B;
auto c=serialize(a); => T is A, but we
I don't understand how Object.factory could help with
serializing. But what would help is if we did get proper
runtime reflection.
All that'd be needed would be to have Object.factory working with
templates, here's how:
unittest{
class A{}
class B{int x;}
A a=new B;
auto
Here's a modification to:
1) hide the intermediate struct (as usual in std.algorithm, I
forgot what this trick is called)
2) work with ranges, not just arrays (ie will work with iota, see
unittest)
3) accept input without "in" attribute;
4) accept arbitrary predicate, not just "==x"
Please co
This is a quirk of DMD, not a language feature.
You can file the implicit import behaviour as a bug.
done:
http://d.puremagic.com/issues/show_bug.cgi?id=8636
On a related note, it would be much clearer if the error messages
used fullyQualifiedName!T instead of just the type name T, as in
more complex code, there WILL be name clashes.
I would guess this would be easy to fix.
On Monday, 10 September 2012 at 00:30:54 UTC, Jonathan M Davis
wrote:
On M
Thanks! the template alias ID solves my problem.
Your code doesn't look good,
What was wrong with it and what would you suggest to improve it?
Also, I noticed you replaced (among other things):
a.map!dg.array
by
a.map!dg().array()
Will the way I'm skipping "()" ever be deprecated? One of th
Can we filter out compiler errors involving _error_ as template
parameter?
Clearly the error is coming from upstream so there's no need to
even show those.
eg:
Error: template mypackage.mymodule.myfunction cannot deduce
template function from argument types !()(_error_)
This works:
import std.stdio;
void main(){
writeln(std.conv.to!double(1));
}
This doesn't compile:
import std.stdio;
void main(){
std.stdio.writeln(std.conv.to!double(1));
}
=>Error: undefined identifier std
So it seems for conv, import std.conv is not needed,
I'd like to have something like:
---
import std.stdio:!writeln,write;
---
which would import all symbols from std.stdio except the ones
listed (writeln,write).
Use case:
The reason is to avoid writing verbose code (specifying all
symbols to import except those 2), example when writing a module
Is there a way to use Object.factory with template classes?
eg:
class A(T){
T x;
}
auto a=Object.factory("A!int");
Right now this fails (returns null).
Use case:
If we had this, it would GREATLY simplify serialization (eg as in
the orange library) by not having to manually register
I'd like to achieve the following:
import std.stdio,std.range,std.algorithm,std.array;
void main(){
auto dg=a=>a*2;
auto a=iota(0,10);
writeln(a.map!dg.array);
}
but this doesn't compile:
Error: variable [...]dg type void is inferred from initializer
delegate (__T26 a)
{
retur
Since this is kind of low level I would guess you cannot just
take a Linux guide and have it work on Mac OS X. Both are Posix
but at this low level the differences between the platforms
start to show up.
BTW, I get "Error: undefined identifier ucontext_t" when
compiling that file on Mac OS X.
related threads:
http://www.digitalmars.com/d/archives/digitalmars/D/learn/3530.html
from Don Clugston:
I have implemented compile-time demangle metafunctions:
static assert( prettynameof!(A)== "class main.A" );
static assert( qualifiednameof!(A) == "main.A" );
static assert( symbolnameof!(A
how to get fully qualified name of a template function?
In the code below I want to get "util.mod.mymethod!(double)"
I tried everything (see below) to no avail, it just returns
"mymethod";
The closest I get is demangle(mangledName!(fun)), which shouldn't
be hard to convert to what I want, but de
79 matches
Mail list logo