The expansion with gotos explains the behaviour nicely! Cool.
The error about fall-through is still missing though?
Also, I'm sorry for my sparse and perhaps erratic replies. For some
reason, most of the messages in this thread are missing from my Inbox.
The only reply I saw was the first one by
Well, I'm still confused by this. I also noticed that the compiler
doesn't complain if I omit the break statements in the generated
switch, but complains normally if I write it out like so:
```
switch (key)
{
case 1: Found 1!.writefln();
break;
case 2:
On 16 April 2014 01:45, via Digitalmars-d digitalmars-d@puremagic.com wrote:
Then you need a compiler option that will prevent @gc, otherwise you risk
libraries pulling in @gc code as quick fixes without library users that want
@nogc noticing the deficiency.
This shouldn't be a problem if you
On 11 April 2014 09:49, Nick Sabalausky
seewebsitetocontac...@semitwist.com wrote:
On 4/11/2014 3:39 AM, Manu wrote:
I just received this email, which told me what my password is!
My password is stored as text?
To be fair, it does warn you about it before you subscribe to the
list. Maybe it
On 8 April 2014 22:11, captaindet 2k...@gmx.net wrote:
[...]
I noticed it works if you move the enum declaration above the
instantiation of template valid.
On 8 April 2014 02:30, bearophile bearophileh...@lycos.com wrote:
On default compile the D code with warnings active.
I'm not sure what you mean? I have the -w and -wi flags always enabled
and I don't get any warnings. I'm using DMD 2.065.
Hello,
I don't understand why so many break statements are needed in this construct:
immutable key = 3;
switch (key)
{
foreach (c; TypeTuple!(1, 2, 3, 4, 5))
{
case c: Found %s!.writefln(c);
break;
}
break; // Default
I was sure adding auto would work. I'm still sure it does in some
cases, but can't try right now.
I guess it depends on the type of foreach?
If I understand foreach correctly, it uses either opApply() or the
range static interface to do its job, and with a range interface
auto does actually
Hello!
You just missed the syntax a little.
Instead of:
int delegate(int) dg = { value = return value + a + 3; };
You can write
auto dg = (int value) { return value + a + 3; }; // Omitted return
type, but had to specify type of value.
or
auto dg = (int value) = value + a + 3; //
Hello!
You can implement static functions that act like members, like so:
---
void myFunc(MyClass c) { ... }
---
Which you will be able to call like:
---
auto c = new MyClass();
c.myFunc();
---
because of uniform function call syntax (UFCS).
But they won't be real methods (virtual member
On 11 March 2014 14:09, Dicebot pub...@dicebot.lv wrote:
On Monday, 10 March 2014 at 15:08:07 UTC, Andrei Alexandrescu wrote:
On 3/10/14, 7:00 AM, Dicebot wrote:
I still don't like disqus :)
Are there better such systems available?
I don't like the very concept of comments integrated
On 21 February 2014 20:00, Tobias Pankrath tob...@pankrath.net wrote:
Depends on how often and where you write those keywords. mut seems to be
quite common and even in D I would not like 'reference' more than 'ref',
especially since it is used in parameter lists.
I think Rust's pub, priv
On 6 Feb 2014 16:56, Adam D. Ruppe destructiona...@gmail.com wrote:
Making scope the default
===
[...]
I just stumbled upon Rust's memory management scheme yesterday and it
seemed similar to this.
On first glance, I really like it.
On Thursday, 26 September 2013 at 22:14:27 UTC, Joseph Rushton
Wakeling wrote:
It's what I was thinking of, but does that also work with a
dynamic array declaration?
int[] arr = new int[n];
Check out std.array.uninitializedArray.
Matej
On Thursday, 26 September 2013 at 22:21:58 UTC, Matej Nanut wrote:
On Thursday, 26 September 2013 at 22:14:27 UTC, Joseph Rushton
Wakeling wrote:
It's what I was thinking of, but does that also work with a
dynamic array declaration?
int[] arr = new int[n];
Check out
On Friday, 23 August 2013 at 22:54:33 UTC, Jonathan M Davis wrote:
Because without static it's a member variable, which means that
you have to
have a constructed object to access it (since it's part of the
object). When
you declare a variable in a class or struct static, then
there's only one
Well, that was fast! I'm glad it's fixed. :)
Hello!
I've run into this issue that I don't understand, maybe someone
can enlighten me. :)
This code:
---
struct Thing
{
int i;
}
void main()
{
t!(Thing.i)();
}
void t(alias a)()
{
return;
}
---
fails to compile with: ‘Error: need 'this' for 't' of type 'pure
nothrow @safe
Hi everyone,
I hope I'm not misunderstanding the spec when this won't compile:
---
import std.conv;
enum Test { a = 0 }
void main() {
ulong l = 0;
auto t = l.to!Test;
}
---
It doesn't compile due to the template not instantiating.
If l is an int, uint or byte, it compiles fine. I'm
On Friday, 12 April 2013 at 04:46:52 UTC, Jesse Phillips wrote:
It is that time, If you would like to see the proposed
std.process include into Phobos please vote yes. If one
condition must be met specify under what condition, otherwise
vote no.
Yes.
Hello,
I noticed there are two different packed bit array
implementations in Phobos: the specialised version of
std.container.Array and std.bitmanip.BitArray. Which one should
be used?
Thanks,
Matej
First of all, const is usually used as just a bridge between
immutable and plain types. You should probably use immutable
there.
As for sharing, immutable variables are implicitly shared, since
they can never change (const variables CAN change somewhere else
in the program). Your globalVar
On Wednesday, 16 January 2013 at 18:35:07 UTC, mist wrote:
Wow, cool stuff indeed.
Preparing for DConf? :)
That's really awesome.
You should write a separate article about this so it doesn't get
lost in the forums!
On Monday, 11 June 2012 at 10:33:22 UTC, Era Scarecrow wrote:
Most curiously while making unittests the asserts fail when
I've confirmed it's working. The difference seems to be if it's
immutable/const vs non, and why this makes a difference I don't
see... Can someone give some light to this?
I either think lazy should remain as it is, or that delegate
syntax should be explicit. But if delegate syntax is explicit,
»lazy« isn't needed anymore. The whole point of it is to have
nice syntax at the call site. Delegate syntax is, however,
conscise enough already.
Bugs due to lazy
On Monday, 7 May 2012 at 22:56:07 UTC, mta`chrono wrote:
What do you meant by D alternatives to wait() and fork() that
could be
used with ptrace(). Maybe I don't understand your intention.
Nevermind with that; I've been confused since there are exec*()
functions in std.process, but no wait()
On Tuesday, 8 May 2012 at 16:41:55 UTC, mta`chrono wrote:
But consider that fork() is a very specific UNIX syscall. There
is
nothing similar like that on Windows. That's maybe why they
didn't wrap
it in Phobos.
Ah yes, very true. I didn't think of that.
Maybe the same applies to wait()
I didn't know about the decimal-point + L notation for reals. It
does seem... surprising. I don't see a reason why ‘R’
wouldn't be a good choice. I also don't see why someone would
write ‘1.0L’ and expect a long.
(1) I've managed this by putting the extern ptrace declaration in
a seperate file and call it via filename.ptrace in my program.
Apparently a new std.process is in the works that does supply a
sort of fork(). I'm sorry for not looking through things
properly before.
Thank you for the reply, your recommendation works.
I could however not find ptrace anywhere in druntime. There is
only one mention of it in std.process, in a comment.
But I do have some other questions:
(1) Can I declare a ptrace function which calls the original
ptrace? (I would like to
Hello everyone,
I would like to know how to call ptrace (the system call) from D.
I don't know what to import or link. If my understanding is
correct, I need to create a .di file of some sort with stuff
declared in it. How would I do this?
Thanks, Matej
Honestly I think having a planet and its moons for »mascots« is
amazing enough!
I find the point on developing on a slower computer very interesting,
and here's my story.
I've been using an EeePC for everything for the past 2.5 years and
until now, I could cope. I'm getting a new laptop this week because I
direly need it at the faculty (some robotics/image
Hello everyone,
I have the following code snippet:
import core.time:TickDuration;
import std.datetime: StopWatch, AutoStart;
void main()
{
auto wait = TickDuration.from!`msecs`(1000);
auto timer = StopWatch(AutoStart.yes);
while (timer.peek wait) // Okay.
{ }
while
So I can call any (void) method without parenthesis without -property?
I guess I'll just add -property to all my programs from now on. But
why isn't .peek() a property? In std.container, for example, the
BinaryHeap has a .front property (even though it isn't declared as
such on dlang.org, but the
I like the look of 8-space indents, but I don't see how I could pull
it off if I use object-oriented features. I use 8-space indents if I
code C, and it seems to work really well. But when you have a class,
and then maybe even an inner class, you practically start with 2
levels of indentation, and
On 20 January 2012 00:46, Jonathan M Davis jmdavisp...@gmx.com wrote:
On Thursday, January 19, 2012 22:10:19 Peter Alexander wrote:
Consistency with C and C++ mainly.
Some people find it convenient, but it is unarguably a frequent source
of bugs that we could do without.
I'd be _very_
until friday.
On 17 January 2012 02:33, Timon Gehr timon.g...@gmx.ch wrote:
On 01/17/2012 12:49 AM, Matej Nanut wrote:
Hey everyone,
I, once again, have a problem with an error I can't seem to figure out!
The situation:
- a class, inherited by five other classes;
- the class having a static
On 17 January 2012 16:54, H. S. Teoh hst...@quickfur.ath.cx wrote:
This may be the cause of your trouble. If the nested class references
members in the outer class, then moving it outside will break it, since
it won't have an outer scope anymore.
T
--
Only boring people get bored. -- JM
On 17 January 2012 18:29, Timon Gehr timon.g...@gmx.ch wrote:
I'm quite sure that the error in your code occurs for the same reason as in
the following code snippet:
class C{
class D{}
static make(){return new D();} // error
}
You can fix it by making D static:
class C{
static
On 17 January 2012 19:07, H. S. Teoh hst...@quickfur.ath.cx wrote:
Andrei's book (The D Programming Language) is quite thorough in
explaining these D constructs. It's a highly recommended buy if you're
doing serious work in D.
T
--
The two rules of success: 1. Don't tell everything you
Hey everyone,
I've gotten that error before but I don't know how I removed it. I don't see
what's wrong, it seems to work most of the time, but not always. I'm sure
there's a reasonable explanation and my understanding of the matter lacks
somewhat. What exactly does it mean?
I'm trying to use
Hey everyone,
I, once again, have a problem with an error I can't seem to figure out!
The situation:
- a class, inherited by five other classes;
- the class having a static function which returns one
if its subclasses depending on the input of a string.
Something like this:
class Node
{
I've never noticed std.conv.parse takes a radix argument, silly me.
And will take
a look at readf from std.stream, definitely.
Thanks!
On 14 January 2012 01:20, Justin Whear jus...@economicmodeling.com wrote:
On Fri, 13 Jan 2012 23:05:19 +0100, Matej Nanut wrote:
While we're at it: what's
I feel it should be left as is: it'll be ambiguous either way and why mess
with how it's in mathematics? If anyone feels uncomfortable using it,
just use std.math.pow. Many other languages don't have this operator so
people coming from them won't know it exists anyway (like me until this
post).
—
, it should be either deprecated or left alone.
It will remain ambiguous to someone at some point, no matter how it's
defined. Part of learning the language though.
On 13 January 2012 19:18, Manu turkey...@gmail.com wrote:
On 13 January 2012 19:41, Matej Nanut matejna...@gmail.com wrote:
I feel it should
My HP 49g+ does -2^2 = -4 as well (with special unary minus), in algebraic
mode. Would love to test it on the 41C, but it only has RPN. ^_^
I've been swayed into the »let's keep it« direction.
I'll start using it, too. It even works as an array operator. =D
On 14 January 2012 00:30, Stewart
You could also try to!int(str.strip), strip() removes
whitespace from the left and right of a string.
You have to import std.string for it.
On 13 January 2012 22:34, Joshua Reusch yos...@arkandos.de wrote:
Am 13.01.2012 22:16, Piotr Szturmaj wrote:
Jorge wrote:
My first question si very
While we're at it: what's the best way to parse in a formatted manner?
For example, if I want to get 5 hexadecimal digits converted into an
uint? And I want to simultaneously advance the string?
sscanf seems fiddly and unsafe.
On 13 January 2012 22:56, bearophile bearophileh...@lycos.com wrote:
And hello from Croatia's neighbour Slovenia. ^_^
The influence sure is growing. I can feel it!
Hello everyone,
I would like to know whether
if (symbol in symbols)
return symbols[symbol];
is any less efficient than
auto tmp = symbol in symbols;
if (tmp !is null)
return *tmp;
Without optimisation, it looks like the first example
On 3 January 2012 17:58, Kai Meyer k...@unixlords.com wrote:
On 01/03/2012 04:07 AM, Jonathan M Davis wrote:
if(auto tmp = symbol in symbols)
return *tmp;
- Jonathan M Davis
+1
Very slick :)
Yup, I'm going with this one. Thanks!
On 3 January 2012 00:27, Timon Gehr timon.g...@gmx.ch wrote:
On 01/03/2012 12:03 AM, RenatoL wrote:
I have:
auto r = new int[][];
Error: new can only create structs, dynamic arrays or class objects
, not int[][]'s
while
auto r = new int[][3];
is ok.
new int[][3] is an alternate
On 2 January 2012 02:51, Timon Gehr timon.g...@gmx.ch wrote:
Is this a regression or a problem with my setup (DMD 2.057 on Ubuntu 11.10
64 bit)?
Can anyone reproduce this?
I get an assert error. Using DMD 2.057 and Arch Linux, but on 32 bit. So I
assume that might be it?
@Heywood Floyd: that works, but what exactly am I permitted to use inside
the handler, as I assume it's a C function? This might be a useless
question as non-atomic operations touching global data aren't supposed to
be in signal handlers, but I'm still interested to know.
@Alex Rønne Petersen:
Hello everyone, I've been fascinated by D lately and have been using it for
all
my school assignments (like simple ray casting and simulated annealing).
What I can't find anywhere is how to do something like
signal(SIGINT, myhandler) (I'm in a Linux environment).
I need this to stop the
56 matches
Mail list logo