24.03.2012 14:13, John написал:
Is there any way to refer to a specific function overload?
For example:
import std.stdio;
import std.traits;
void foo() {}
void foo(int x) {}
void main() {
writeln(foo.mangleof);
writeln(ParameterTypeTuple!(foo).stringof);
}
Both of these statements
21.03.2012 13:35, kennytm пишет:
Mantismail.mantis...@gmail.com wrote:
[...]
# identifier statement
You mean 'declaration'.
Not necessarily, this could be used anywhere a mixin can be.
[...]
The syntax may conflict with '#line'.
I didn't know. The choice for the symbol is not that
Hello,
since people discussed a lot about user-defined attributes recently,
I've been thinking about a way to implement it with a string mixins. The
problem with them is their syntax - it's far from what we want to use in
everyday job. I understand, they should be easily distinguished at use
16.03.2012 20:23, H. S. Teoh пишет:
I'm writing some unittests with very repetitive tests for a myriad of
different types, so I wrote a helper function:
version(unittest) {
void checkConsistency(T...)(T args) {
foreach (a; args) {
16.03.2012 20:35, H. S. Teoh пишет:
[...]
Actually, I found the solution: the compiler understands __FILE__ and
__LINE__ in compile-time arguments too, so this works: void
checkConsistency(string file=__FILE__, size_t line=__LINE__, T...)(T
args) { ... } It's a bit painful with the assert
12.03.2012 6:01, Robert Jacques пишет:
On Sun, 11 Mar 2012 21:49:52 -0500, Mantis mail.mantis...@gmail.com
wrote:
[...]
That's the point of discussion. Fields of structure may not be optimized
away, because they are not independent variables. In D you have
unchecked pointer-to-pointer casts
12.03.2012 4:00, Robert Jacques пишет:
On Sun, 11 Mar 2012 18:15:31 -0500, Timon Gehr timon.g...@gmx.ch wrote:
On 03/11/2012 11:58 PM, Robert Jacques wrote:
Manu was arguing that MRV were somehow special and had mystical
optimization potential. That's simply not true.
Not exactly mystical,
12.03.2012 4:16, Chad J пишет:
I remember doing colored terminal output in Python. It was pretty
nifty, and allows for some slick CLI design. I think D can do better
by putting it in the standard library.
I was thinking something along the lines of this:
11.03.2012 3:45, Robert Jacques пишет:
[...]
Manu, please go read the D ABI (http://dlang.org/abi.html). Remember,
your example of returning two values using Tuple vs 'real' MRV? The D
ABI states that those values will be returned via registers. Returning
something larger? Then the NVRO kicks
10.03.2012 3:01, Adam D. Ruppe пишет:
On Saturday, 10 March 2012 at 00:48:56 UTC, Jonathan M Davis wrote:
From the sounds of it, Adam thinks that it's bad
Indeed. I have an advantage here though: it is an
objective fact that -property breaks a lot of existing
D code.
We can (and have)
08.03.2012 22:08, Manu пишет:
I find myself really wishing for proper multiple return values almost
every day, particularly when I work with maths heavy code, and
especially for efficiently returning error codes in functions I'd
rather not throw from.
Many maths-y functions return some sort of
09.03.2012 1:28, Manu пишет:
[...]
The problem is, that approach feels like a double negative to me. A
tuple is fundamentally a structure, returned by value. Implementing
hacks to subvert the standard behaviour of returning a structure by
value is unintuitive for a start, and you also lose
09.03.2012 2:23, Manu пишет:
On 9 March 2012 01:56, Mantis mail.mantis...@gmail.com
mailto:mail.mantis...@gmail.com wrote:
[...]
Is tuple required to be anonymous struct? I thought it's
implementation details that may be done the other way if tuples
implemented in language
06.03.2012 8:04, Chad J пишет:
On 03/06/2012 12:07 AM, Jonathan M Davis wrote:
If you dereference a null pointer, there is a serious bug in your
program.
Continuing is unwise. And if it actually goes so far as to be a segfault
(since the hardware caught it rather than the program), it is
04.03.2012 3:42, Andrej Mitrovic пишет:
[...code...]
I want to avoid writing check() twice. I only have to statically
check a field of a member if it's of a certain type (Foo).
One solution would be to use a boolean:
void test(T)(T t)
{
bool isTrue = true;
static if (is(T == Foo))
24.02.2012 21:34, simendsjo пишет:
char[] a;
auto b = cast(void*)a;
auto c = cast(char[])b; // Error: e2ir: cannot cast b of type
void* to type char[]
Generally, you should not cast a struct to pointer and vise-versa.
Besides, size of array structure is larger than size of
21.02.2012 14:46, Joshua Reusch пишет:
interface I {
final int foo(I other, int a, int b) {
return other.foo(a,b) + a*b;
}
int foo(int a, int b);
}
class A : I {
int foo(int a, int b) {
return a*b;
}
}
void main() {
A a = new A;
a.foo(5,5);
a.I.foo(a, 5,5);
a.foo(a, 5,5); //line 22
}
21.02.2012 17:24, deadalnix пишет:
struct stuff {
private Exception delegate() exceptionBuilder = delegate Exception() {
return new Exception(foobar);
};
}
The following piece of code trigger a compiler error : delegate
module.stuff.__dgliteral1 function literals cannot be class members
Why
21.02.2012 21:42, Robert Rouse пишет:
...
mixin(alias _method ~ toLower(typeid(T)) ~ ; );
...
Try
typeid(T).toString();
or
typeof(T).stringof;
typeid does not return a string type.
17.02.2012 4:30, bearophile пишет:
After seeing this interesting thread:
http://stackoverflow.com/questions/9314534/why-does-changing-0-1f-to-0-slow-down-performance-by-10x
Do you know if there's a simple way to perform _MM_SET_FLUSH_ZERO_MODE in D?
According to Agner that operation is not
18.02.2012 2:50, H. S. Teoh пишет:
...
You cannot have ref local variable, so e is a copy in any case. It may
be a class reference or a pointer, so calling potentially non-const
methods is probably not safe here, but assignment shouldn't give you
problems.
18.02.2012 7:51, H. S. Teoh пишет:
On Sat, Feb 18, 2012 at 05:19:52AM +0200, Mantis wrote:
18.02.2012 2:50, H. S. Teoh пишет:
...
You cannot have ref local variable, so e is a copy in any case. It
may be a class reference or a pointer, so calling potentially
non-const methods is probably
13.02.2012 9:45, Alf P. Steinbach пишет:
I first started with a Windows message box program and installing an
IDE. I'm now using the VisualD plug-in with the Visual Studio 10
Shell, after battling a bit with installation of service pack 1 for
Visual Studio. VisualD works, sort of, except the
13.02.2012 10:16, Mantis ?:
...snip...
What is unicode_based_api file? I don't see it in core.sys.windows:
http://github.com/D-Programming-Language/druntime/tree/master/src/core/sys/windows
Oh, I guess I understand what you're trying to do. IIRC, druntime source
files get compiled
03.02.2012 22:03, xancorreu пишет:
Al 03/02/12 18:07, En/na Trass3r ha escrit:
I deduce so that there is no official support for that. If it's,
it's a pain.
Pain? Writing such a system can be done in a couple of lines.
How? I don't know how to do that. How to read user current locale?
An
30.01.2012 16:37, Jared пишет:
However, this doesn't seem to be possible in D.
Why not?
import std.stdio;
class Exception1 : Throwable { this( string s ) { super( s ); } }
class Exception2 : Throwable { this( string s ) { super( s ); } }
void foo() {
throw new Exception1( foo );
}
void
29.01.2012 22:42, Walter Bright пишет:
On 1/29/2012 6:17 AM, bearophile wrote:
D2 style guide should *require* D2 to be edited using a mono-spaced
font, and
the D2 front-end should enforce this with a -ms compiler switch.
What? How could the compiler possibly know what font was used in your
28.01.2012 15:31, Jos van Uden пишет:
import std.stdio, std.stream, std.string, std.range;
void main() {
int countPalindromes;
auto infile = new BufferedFile(unixdict.txt);
foreach (char[] line; infile) {
if (line.walkLength 1) {
line.toLowerInPlace;
if (line == line.dup.reverse)
26.01.2012 2:40, Jonathan M Davis пишет:
What type safety? You're dealing with a uint (or ushort or ulong) with a bunch
of specific bits set which represent flags. What other type would you want? You
could typedef it I suppose (well, use the TypeDef library type when it's
merged in anyway), but
24.01.2012 8:43, Andrej Mitrovic пишет:
But I did implement them poorly, this is better:
import std.traits;
template KeyType(AA)
if (isAssociativeArray!AA)
{
static if (is(AA V : V[K], K))
{
alias K KeyType;
}
}
template ValueType(AA)
if
24.01.2012 20:49, bearophile пишет:
Mantis:
Of course, most likely that user already did type check, but if not,
this will give less cryptic error:
Error: static assert Not associative array: int
instantiated from here: KeyType!(int)
, instead of:
Error: template instance KeyType!(int
24.01.2012 22:48, Mars пишет:
Hello everybody.
I have to convert a char* (from a C function) to long. At the moment
I'm using
long foo = to!long( to!string(bar) );
but this doesn't feel right... with 2 to calls. Is this the way to go?
Or is there something better?
Mars
This seems to work:
23.01.2012 20:06, bearophile пишет:
Ellery Newcomer:
void main(){
for ({int x=0; short y=0;} x 10; x++, y++){
}
}
I don't understand, is that a compiler bug?
Aren't x and y in a sub-scope that ends before you use x and y?
Bye,
bearophile
According to specs, this is
2012/1/22 Walter Bright newshou...@digitalmars.com:
http://news.ycombinator.com/item?id=3495283
and getting rid of unsigned types is not the solution to signed/unsigned
issues.
Would it be sane to add integer overflow/carry runtime checks in
-debug builds? This could probably solve such
2012/1/22 Jonathan M Davis jmdavisp...@gmx.com:
Another potentially nasty situation is subtraction. It
can do fun things when you subtract one unsigned type from another if you're
not careful...
It is unrelated to unsigned types in any way, isn't it?:
int a = 2_000_000_000;
assert( a + a ==
2012/1/20 bearophile bearophileh...@lycos.com:
Walter has recently closed a bug report without fixing it and without an
answer, it's about contract based programming:
http://d.puremagic.com/issues/show_bug.cgi?id=5024
So I'm asking for more info here.
As reference I use this little program
2012/1/17 simendsjo simend...@gmail.com:
Where is documentation on exceptions located?
Not here http://www.d-programming-language.org/exception-safe.html
or here http://www.d-programming-language.org/errors.html
or here http://www.d-programming-language.org/phobos/std_exception.html
Do I
2012/1/17 Vladimir Panteleev vladi...@thecybershadow.net:
On Tuesday, 17 January 2012 at 01:44:37 UTC, Vladimir Panteleev wrote:
On Monday, 16 January 2012 at 19:28:42 UTC, Jerry wrote:
As far as I can tell, the only way to do this would be to capture every
chunk of text, then iterate to
2012/1/17 Mehrdad wfunct...@hotmail.com:
?!?!?
Documentation is frequently out of date, but code isn't.
And ideally, the code wouldn't NEED documentation, BECAUSE it SAYS what it's
doing.
Maybe - if you have access to function's source text. But we were
talking about a specific feature on
2012/1/17 Andrei Alexandrescu seewebsiteforem...@erdani.org:
I hate I must ask this:
Can't find any arguments for either version, but subjectively I like
non-property version more.
2012/1/15 Alex Rønne Petersen xtzgzo...@gmail.com:
Hi,
I don't know how many times I've made the mistake of passing a local
variable to a function which takes a 'ref' parameter. Suddenly, local
variables/fields are just mutating out of nowhere, because it's not at all
obvious that a function
2012/1/13 bearophile bearophileh...@lycos.com:
This is the third time I see people trip on power operator precedence:
http://d.puremagic.com/issues/show_bug.cgi?id=7268
Some people expect this:
(-10 ^^ 2)
To be 100 instead of -100
(Note: Python here uses the same operator precedences.)
Do
All is passed, to print, say, 50 signs after period use following:
writefln(%.50f, var);
2012/1/12 dsmith dsm...@nomail.com:
How do you increase floating point precision beyond the default of 6?
example:
double var = exp(-1.987654321123456789);
writeln(var);
-- 0.137016
Assuming this
2012/1/9 Zachary Lund ad...@computerquip.com:
On 01/08/2012 05:33 PM, Zachary Lund wrote:
Someone brought an example that I thought was rather strange an
preventable in the IRC this evening. Take this example:
int[3] bob = [ 1, 2, 3];
The above will compile fine and the program may even
2012/1/6 Manu turkey...@gmail.com:
Okay, so I was trying to link to a C lib, and I realised... DMD doesn't
support/produce VS compatible libs.
I should have realised this sooner, noting the cv debuginfo.
So like... WTF?
How am I supposed to use DMD in Windows in anything other than trivial,
2012/1/6 Trass3r u...@known.com:
There is indeed a coff2omf tool for static libs and here's the funny thing:
you have to pay for it :D
Didn't notice it's from a non-free package.
2012/1/5 Andrei Alexandrescu seewebsiteforem...@erdani.org
http://l33ts.org/forum/Thread-**my-online-multiple-language-**
compiler?pid=575304#pid575304http://l33ts.org/forum/Thread-my-online-multiple-language-compiler?pid=575304#pid575304
Andrei
Good, but what is the point in having an
2012/1/5 Raivo F. rai...@gmail.com
Hi!
I'm new to D programming language, altough have solid background in other
languages.
Currently I struggle with setting up simple OpenGL application.
I found D/OpenGL package called GLAD:
http://code.google.com/p/glapid/
First, it didn't include
2012/1/4 Manu turkey...@gmail.com
Does returning a tuple give any ABI guarantees? How can I be sure multiple
return values will return in consecutive registers?
What if the return types are of different types, a float and an int... can
I expect each to return in their own register types
2012/1/2 Adam D. Ruppe destructiona...@gmail.com
On Monday, 2 January 2012 at 01:14:43 UTC, Mail Mantis wrote:
If I undestood you correctly...
Potentially, yes, But, from syntactical point of view, is there any [...]
http://drdobbs.com/blogs/**tools/229401068http://drdobbs.com/blogs/tools
Just a small tip for those people, who use following code style:
if( cond ) {
body
} else {
body
}
I've found it very convenient to attach unittest block to my function
declatarions in a same way:
private int find_pos_divisor( int first, int second ) {
int temp;
while( second ) {
2012/1/2 Jonathan M Davis jmdavisp...@gmx.com
And I find that style to be seriously harming readability (braces should
always
be on their own line IMHO), but I guess that if you like it, it makes
sense.
- Jonathan M Davis
I understand your point, but don't share it - since tabulation
2012/1/2 Sean Cavanaugh worksonmymach...@gmail.com
On 12/29/2011 10:16 AM, Trass3r wrote:
On Thursday, 29 December 2011 at 16:00:47 UTC, Vladimir Panteleev wrote:
On Thursday, 29 December 2011 at 15:58:55 UTC, Trass3r wrote:
What's the stance on using C++11 features in the dmd source code
2012/1/2 Walter Bright newshou...@digitalmars.com
On 1/1/2012 4:30 PM, Mail Mantis wrote:
As for D - it already natively
supports many C++11 features(or vise-versa), but I wonder if the
user-defined
literals will ever make into it.
With CTFE D has far better than user defined literals
54 matches
Mail list logo