On Monday, 6 August 2012 at 23:42:45 UTC, Era Scarecrow wrote:
On Monday, 6 August 2012 at 22:28:40 UTC, RivenTheMage wrote:
On Monday, 6 August 2012 at 21:51:24 UTC, Andrej Mitrovic
wrote:
There is no "outer". A nested struct has the same access as a
nested static class, meaning no access to
import std.stdio;
template isType(alias s)
{
enum isType = !__traits(compiles,mixin("typeof(s)"));
}
void main()
{
// writeln(isType!int);// Error: template instance isType!(int)
isType!(int) does not match template declaration isType(alias s)
writeln(__traits(compiles,mixin("t
Am 07.08.2012 09:51, schrieb Zhenya:
import std.stdio;
template isType(alias s)
{
enum isType = !__traits(compiles,mixin("typeof(s)"));
}
void main()
{
//writeln(isType!int);// Error: template instance isType!(int)
isType!(int) does not match template declaration isType(alias s)
w
On 08/07/12 09:51, Zhenya wrote:
> import std.stdio;
>
> template isType(alias s)
> {
> enum isType = !__traits(compiles,mixin("typeof(s)"));
> }
>
> void main()
> {
> //writeln(isType!int);// Error: template instance isType!(int)
> isType!(int) does not match template declaration isType
On Tuesday, 7 August 2012 at 09:47:58 UTC, Artur Skawina wrote:
On 08/07/12 09:51, Zhenya wrote:
import std.stdio;
template isType(alias s)
{
enum isType = !__traits(compiles,mixin("typeof(s)"));
}
void main()
{
//writeln(isType!int);// Error: template instance
isType!(int) isType!(in
dmd 2.060 64bit ubuntu:
// Doesn't work:
auto r =
ctRegex!(r"/api/places/(id|related|search|count)\.(json|xml)",
"g");
// Works:
auto r =
regex(r"/api/places/(id|related|search|count)\.(json|xml)", "g");
Hey,
let's say I have a simple struct and I want to give it an
opEquals like this.
struct Point
{
int x, y;
bool opEquals(R)(R rhs) { return x == rhs.x && y == rhs.y; }
}
With this I can't call opEquals on const instances of Point,
because dmd says
bug.d(13): Error: function bug.P
On Tue, Aug 7, 2012 at 12:42 PM, Zhenya wrote:
>> Template alias parameters do not accept built-in types.
The trick is:
- A template type parameter (like (T)) recognizes types
- A template alias parameter(like (alias a)) recognizes names, symbols.
A built-in type is 'purely' a type. It's a key
Really? It compiles: http://dpaste.dzfl.pl/e0470f9a
On 07-Aug-12 16:06, Andrea Fontana wrote:
dmd 2.060 64bit ubuntu:
// Doesn't work:
auto r = ctRegex!(r"/api/places/(id|related|search|count)\.(json|xml)",
"g");
Could be. It is experimental and is known to have bugs.
What is the exact problem statement?
// Works:
auto r = regex(r"/api/place
Given e.g. a function template
void f(T ...)(T t) {
writeln(t.length);
}
How can I call this function with an already-constructed tuple
but pass the pule as an expressiontuple?
auto v = tuple(1, 2, 3);
f(v);
In the case above, f will print 1 because 1 tuple is given to the
function, but I
On 8/7/12, "Øivind" wrote:
> How can I call this function with an already-constructed tuple
> but pass the pule as an expressiontuple?
>
> auto v = tuple(1, 2, 3);
> f(v);
Use the .expand property:
f(v.expand)
I have a threaded connection:
class ThreadedConnection : Connection {
protected Thread _thread = null;
@property Thread thread() { return _thread; }
void run() {
if(_thread is null) {
_thread = new Thread(&(super.run));
_thread.isDaemon = true;
On Tuesday, 7 August 2012 at 16:11:05 UTC, Andrej Mitrovic wrote:
On 8/7/12, "Øivind" wrote:
How can I call this function with an already-constructed tuple
but pass the pule as an expressiontuple?
auto v = tuple(1, 2, 3);
f(v);
Use the .expand property:
f(v.expand)
Works like a charm. Than
On 08/07/2012 06:40 AM, Tobias Pankrath wrote:
> bool opEquals(R)(R rhs) { return x == rhs.x && y == rhs.y; }
> bool opEquals(R)(R rhs) const { return x == rhs.x && y == rhs.y; }
I strongly recommend that only the const version should be defined. That
would work on both mutable and immutable ob
On Tuesday, 7 August 2012 at 16:46:04 UTC, Ali Çehreli wrote:
On 08/07/2012 06:40 AM, Tobias Pankrath wrote:
> bool opEquals(R)(R rhs) { return x == rhs.x && y == rhs.y; }
> bool opEquals(R)(R rhs) const { return x == rhs.x && y ==
rhs.y; }
I strongly recommend that only the const version shoul
[code]
import std.regex;
enum Token : string {
Blank = r"\s+"
}
void main() {
const string text = "Foo Bar";
// text.split(regex(Token.Blank)); // don't work
const string blank = Token.Blank;
text.split(regex(blank)); // work
}
[/code]
Can me so
On 07-Aug-12 21:05, Namespace wrote:
[code]
import std.regex;
enum Token : string {
Blank = r"\s+"
}
void main() {
const string text = "Foo Bar";
// text.split(regex(Token.Blank)); // don't work
const string blank = Token.Blank;
text.split(regex(blank)); // work
}
[/c
On 8/7/12, "Øivind" wrote:
> The last one then becomes f(v0.expand, v1.expand)
Yeah. It's somewhat possible to use a helper function for multiple
TypeTuples, but the problem is D functions cannot return language
tuples (only TypeTuple from std.typecons which is what the tuple()
call creates) so y
Am Mon, 06 Aug 2012 14:21:37 +0200
schrieb "Minas Mina" :
> I want to write a fibonacci(n) function that calculates the
> result.
> a) if n is known at compile time, use a template
> b) if not, use a normal function
>
> I know how to write a template version:
> template fib(ulong n)
> {
>
On Tuesday, August 07, 2012 15:40:18 Tobias Pankrath wrote:
> Hey,
>
> let's say I have a simple struct and I want to give it an
> opEquals like this.
>
> struct Point
> {
> int x, y;
> bool opEquals(R)(R rhs) { return x == rhs.x && y == rhs.y; }
> }
>
>
> With this I can't call opEquals on con
On Tuesday, 7 August 2012 at 17:14:03 UTC, Dmitry Olshansky wrote:
On 07-Aug-12 21:05, Namespace wrote:
[code]
import std.regex;
enum Token : string {
Blank = r"\s+"
}
void main() {
const string text = "Foo Bar";
// text.split(regex(Token.Blank)); // don't work
const string b
On Tuesday, August 07, 2012 21:14:00 Dmitry Olshansky wrote:
> isSomeString!T regression? See enum & std.traits topic in d.D.
> Seems like it will work again in 2.061...
Yeah. In 2.060, std.traits doesn't treat enums as their base type for stuff
like isSomeString and isIntegral, which is the prob
On Tue, Aug 7, 2012 at 7:35 PM, Andrej Mitrovic
wrote:
> Yeah. It's somewhat possible to use a helper function for multiple
> TypeTuples, but the problem is D functions cannot return language
> tuples (only TypeTuple from std.typecons which is what the tuple()
> call creates) so you would always
On Aug 7, 2012, at 9:36 AM, David wrote:
> I have a threaded connection:
> ...
> Since this is a daemon thread, I'd expect it to stop/terminate when the main
> thread stops. This is not the case (it keeps running), is this a known bug
> and how can I workaround this?
Daemon threads will keep r
Hi,
I tried using named submatch for ctRegex... it works but
seemingly only for maximum 1 named submatch...
OK (\w changed to \S to avoid, out of memory)
`(?P\S+)\s*=\s*(\d+);`
`(?\S+)\s*=\s*(?P\d+);`
NOT OK
`(?P\w+)\s*=\s*(?P\d+);`
Is this a known bug? I used the regex example from the Libr
On 08-Aug-12 00:24, Daniel wrote:
Hi,
I tried using named submatch for ctRegex... it works but seemingly only
for maximum 1 named submatch...
Great! I never tried ;) Should just work though...
OK (\w changed to \S to avoid, out of memory)
`(?P\S+)\s*=\s*(\d+);`
`(?\S+)\s*=\s*(?P\d+);`
NOT O
On 8/7/12, Philippe Sigaud wrote:
> You can also take the 'dual' of your solution and have a template that
> makes a function automatically expand tuples
But that doesn't work for variadic templates, which is the OP's case:
int foo(T...)(T t) { return 1; }
alias expander!foo efoo; // error
On Tuesday, 7 August 2012 at 20:51:28 UTC, Dmitry Olshansky wrote:
Great! I never tried ;) Should just work though...
hehe :)
That all being said experimental tag on ctRegex in DDoc is here
for a reason, and that is: ctRegex can't compile nor match full
regex testsuite.
Understood, thank
On 8/6/12, Andrej Mitrovic wrote:
> Unfortunately anything big won't work because I get out of memory errors when
> compiling the
> D wrapper.
It doesn't seem to be caused by any infinite loops, DMD just simply
runs out of memory. I've enabled some printf's and created a log file:
dmd -v -c _en
Daemon threads will keep running until the process terminates.Forcibly halting them any earlier risks leaving mutexes they hold in a
locked state, etc, which could break shutdown and hang the app.
Typically, you'll want to have a shared module dtor communicate to any
daemon threads that it's tim
On 07-08-2012 21:38, Sean Kelly wrote:
On Aug 7, 2012, at 9:36 AM, David wrote:
I have a threaded connection:
...
Since this is a daemon thread, I'd expect it to stop/terminate when the main
thread stops. This is not the case (it keeps running), is this a known bug and
how can I workaround t
Hi,
using std.concurrency, is it possible to print an exception if a thread
throws (and the main thread is still running) ? It just terminates and
prints nothing. I tried to catch it and send as a message to the main
thread, but haven't succeeded so far.
--
mk
Am Mon, 6 Aug 2012 18:25:01 +0200
schrieb Andrej Mitrovic :
> On 8/6/12, CrudOMatic wrote:
> > another quick question - are these allocations automatically
> > entered into the GC heap? If so then I can just disable garbage
> > collection?
>
> No, there is the standard C malloc/free in std.c.std
On 08/07/2012 06:25 PM, Martin Krejcirik wrote:
> Hi,
>
> using std.concurrency, is it possible to print an exception if a thread
> throws (and the main thread is still running) ? It just terminates and
> prints nothing. I tried to catch it and send as a message to the main
> thread, but haven't s
On Tue, Aug 7, 2012 at 11:31 PM, Andrej Mitrovic
wrote:
> On 8/7/12, Philippe Sigaud wrote:
>> You can also take the 'dual' of your solution and have a template that
>> makes a function automatically expand tuples
>
> But that doesn't work for variadic templates, which is the OP's case:
>
> int f
Hello,
there is the following C function:
void foo(const void** data);
in C I can do:
int data[N][M];
data[0][0] = ..;
data[0][1] = ..;
data[1][0] = ..;
data[1][1] = ..;
foo(data); // for C code it works and in D code it doesn't (compile, but
do nothing)
I've "solved" the problem like this
On 08/07/2012 11:07 PM, Alexandr Druzhinin wrote:
> Hello,
> there is the following C function:
>
> void foo(const void** data);
>
> in C I can do:
>
> int data[N][M];
>
> data[0][0] = ..;
> data[0][1] = ..;
> data[1][0] = ..;
> data[1][1] = ..;
>
> foo(data); // for C code it works and in D code
On Aug 7, 2012, at 4:01 PM, David wrote:
>> Daemon threads will keep running until the process terminates.Forcibly
>> halting them any earlier risks leaving mutexes they hold in a
> locked state, etc, which could break shutdown and hang the app. Typically,
> you'll want to have a shared module
On Aug 7, 2012, at 5:41 PM, Alex Rønne Petersen wrote:
> On 07-08-2012 21:38, Sean Kelly wrote:
>> On Aug 7, 2012, at 9:36 AM, David wrote:
>>
>>> I have a threaded connection:
>>> ...
>>> Since this is a daemon thread, I'd expect it to stop/terminate when the
>>> main thread stops. This is no
On Wed, Aug 8, 2012 at 7:01 AM, Philippe Sigaud
wrote:
>> But that doesn't work for variadic templates, which is the OP's case:
>>
>> int foo(T...)(T t) { return 1; }
>> alias expander!foo efoo; // error
>
> The template can easily be modified to deal with template functions,
> but in that case,
41 matches
Mail list logo