On Monday, 23 June 2014 at 01:16:49 UTC, Evan Davis wrote:
As the subject says, I would like to pass around an array of
functions. The trick is, that the functions have different type
signatures. Is there a way to put the two functions
int foo(int a, int b);
bool bar(bool a, bool b);
into one
On Monday, 23 June 2014 at 01:16:49 UTC, Evan Davis wrote:
As the subject says, I would like to pass around an array of
functions. The trick is, that the functions have different type
signatures. Is there a way to put the two functions
int foo(int a, int b);
bool bar(bool a, bool b);
into one
As the subject says, I would like to pass around an array of
functions. The trick is, that the functions have different type
signatures. Is there a way to put the two functions
int foo(int a, int b);
bool bar(bool a, bool b);
into one array, that I can pass around and cast as necessary?
Thank
On 06/22/2014 05:01 PM, WhatMeWorry wrote:
After hours of reading (obviously not comprehending) std.process and
looking at code samples, I still can't even do something this simple.
Open a Windows command line and run miscellaneous commands. Only the
first command, dir" is shown in the final out
After hours of reading (obviously not comprehending) std.process
and looking at code samples, I still can't even do something this
simple. Open a Windows command line and run miscellaneous
commands. Only the first command, dir" is shown in the final
output.
auto pipe = pipeShell("dir", Redi
Cool! Only this does not show me where the error was. __FILE__
and __LINE__ is not any help here, because it's a template. Any
other way to find out where the actual error was?
Nah, this gives me lots of compiler crap, like .empty and others,
when compiler tries to compile them.
On Sun, Jun 22, 2014 at 5:02 PM, monnoroch via Digitalmars-d-learn
wrote:
> Thanks a lot!
> There is a problem though: when i pass incorrect parameters to
> such a method, it says, that S has no such field, which is a
> misleading error message.
You can test the mixin with static if, like this:
On Sun, Jun 22, 2014 at 5:04 PM, monnoroch via Digitalmars-d-learn
wrote:
> There is also a problem: when i declare opDispatch to be private,
> i still have access to this forwarding from another package. Is
> it a bug or what?
I don't know. I never used private in conjunction with a template.
Le
Thanks a lot!
There is a problem though: when i pass incorrect parameters to
such a method, it says, that S has no such field, which is a
misleading error message.
There is also a problem: when i declare opDispatch to be private,
i still have access to this forwarding from another package. Is
it a bug or what?
On 2014-06-22 14:11:58 +, sigod said:
In the video "Case Studies In Simplifying Code With Compile-Time
Reflection" [was pointed out][0] that it is possible to reflect on
imported packages.
So, I tried:
reflection.d:
```
import std.stdio;
import test.module1;
import test.module2;
void m
In the video "Case Studies In Simplifying Code With Compile-Time
Reflection" [was pointed out][0] that it is possible to reflect
on imported packages.
So, I tried:
reflection.d:
```
import std.stdio;
import test.module1;
import test.module2;
void main() {
foreach (m; __traits(allMemb
This question seems more fit for the main D newsgroup.
Should I create new thread in the main newsgroup?
Look in Bugzilla if there is a enhancement request.
Yeah. I found one: https://issues.dlang.org/show_bug.cgi?id=456
On Sunday, 22 June 2014 at 12:52:11 UTC, sigod wrote:
module.d: (or just `module module;` in source file)
I was wrong about `module module;` declaration.
sigod:
Shouldn't keywords be disallowed for module names?
I agree. (Walter seems not too keen on strictness). This question
seems more fit for the main D newsgroup. Look in Bugzilla if
there is a enhancement request.
Bye,
bearophile
E.g.:
module.d: (or just `module module;` in source file)
```
import std.stdio;
void main() {
foreach (m; __traits(allMembers, mixin(__MODULE__))) { //
module.d-mixin-4(4): Error: expression expected, not 'module'
writeln(m);
}
}
```
Documentation says:
Package names cannot be
If these rules are not so clear and have some exceptions (but I
don't understand why they are needed) then some documentation
needed about this. But I would prefer to have result of uint
substraction like uint, and char substraction like char. If we
will changing all the types it will be kind o
Uranuz:
Why there are so complicated rules in the *new* language.
It's hard to understand the logic.
Despite D being only 14 years old, one of its rules is to
(usually) give the same results if you write code that is valid
in C. This means it has to follow many rules of C language. If
you t
On Sunday, 22 June 2014 at 11:57:48 UTC, Uranuz wrote:
Another stupid question. Using this logic substraction for two
uint values should return int too, because it can produce
negative result. Am I right or not?
Now this code
import std.stdio;
void main()
{
uint a = 50;
uint
Uranuz:
Another stupid question. Using this logic substraction for two
uint values should return int too, because it can produce
negative result. Am I right or not?
There are no stupid questions, there are only some stupid answers.
Generally uint - uint generates a result with a [-4_294_967_
Another stupid question. Using this logic substraction for two
uint values should return int too, because it can produce
negative result. Am I right or not?
In D operations among chars return a int. The same happens in
C/C++.
If you subtract a char from a char in general you can have a
negative result, that can't fit in a char. So what's buggy is
your thinking.
Ok. Thank you! I never thought about it that way
Uranuz:
But what @nogc changes in there so I should use this modifier?
@nogc will be present in dmd 2.066, it means that the function
(and all the functions it calls) can't perform operations that
cause a call to GC functions.
Sometimes GC operations are a source of performance loss.
Bye,
Uranuz:
But I don't understand why in expression where both of
arguments have type char:
return c - '0';
I have resulting type int. It's very strange for me and looks
very buggy)
In D operations among chars return a int. The same happens in
C/C++.
If you subtract a char from a cha
On Saturday, 21 June 2014 at 18:22:54 UTC, Paul wrote:
I wrote some (JSONRPC and TXTRPC) and used them with vibe. I
can send you via email
Hi Paul, alternatively you could upload your code to GitHub or
some similar place and place the link here. Then you also have a
means to "proof" that the
In expression
return c - 'a' + 10;
I could think that 10 has type int and resulting value promoted
to the largest type. But I don't understand why in expression
where both of arguments have type char:
return c - '0';
I have resulting type int. It's very strange for me and looks
ve
ushort hexValue(in char c) pure nothrow @safe @nogc
else
return ushort.max;
I understand what pure, nothrow and @safe mean there. But what
@nogc changes in there so I should use this modifier? Is it
logical specifier that this function can be used without garbage
Thanks, that did the trick.
Here's a summary post for anyone else with the same problem:
Problem:
DMD uses GCC to perform linking. On Hardened Gentoo (and
derivatives like Sabayon), GCC implies -fPIE, which causes
linking to fail if phobos and druntime were not compiled with
-fPIC. You can ch
Uranuz:
bool isDigit(char c) nothrow
This function is already in Phobos, it's std.ascii.isDigit.
ushort hexValue(char c) nothrow
Better to use this signature (assuming you want a ushort result,
despite a ubyte suffices and a uint is faster):
ushort hexValue(in char c) pure nothrow @saf
I have the following programme
import std.stdio;
bool isDigit(char c) nothrow
{
return c >= '0' && c <= '9';
}
ushort hexValue(char c) nothrow
{
if( isDigit(c) )
return c - '0';
else if (c >= 'a' && c <= 'f')
return c - 'a' + 10;
e
On Saturday, 21 June 2014 at 20:03:26 UTC, Ali Çehreli wrote:
> Now, http://dlang.org/struct.html#AssignOverload says:
>
> ref S opAssign(S s)
> {
Note that opAssign takes by-value. The post-blits that you see
are due that copy. i.e. b in main is copied to the argument
that opAssign
32 matches
Mail list logo