On 1/12/22 00:59, JG wrote:
> I want to make a type which has two fields x and y but can
> also be indexed with [0] and [1] checked at compile time.
std.typecons.Tuple already does that. You can add "member functions"
like foo() below by taking advantage of UFCS:
import std.typecons;
alias P
Gareth Charnock Wrote:
> And now I see there was an article about that on website all
> along.
And that article is here:
http://www.digitalmars.com/d/2.0/migrate-to-shared.html
Ali
bearophile Wrote:
> This prints 42 0.00 with the latest dmd2 and 42 nan with an older dmd1.
> It can be a bug:
It prints garbage here with 2.037. :/
As I've responded to my own post :), I think the initialization is meant only
for static objects.
>
> import std.c.stdio: printf;
>
> stru
Ali Cehreli Wrote:
> (I must be missing something here
Yes I am! :)
> I've been under the impression that struct members would always be
> initialized. Having seen D an init-happy language compared to C and C++,
> that's what I would have expected. :)
I still think
(I must be missing something here; this is such a fundamental operation and I
can't find a bug report on it.)
I've been under the impression that struct members would always be initialized.
Having seen D an init-happy language compared to C and C++, that's what I would
have expected. :)
Should
A Bothe Wrote:
> I've found a problem that occurred since DMD 2.034:
I am testing it with 2.036.
> When I've created a dynamic array like
> string[] a;
I like to see it a "slice." Even if we go with "dynamic array," I see it as an
empty dynamic array.
> and I want to assign something via the
Ok, I messed up my previous comment while moving rmcguire's lines around.
Trying again... Also, I am not sure about the last bit now. :)
rmcguire Wrote:
> why is this not a compiler bug?
> because:
> import std.stdio;
>
> void main() {
> float f=0.01;
Just an information: 0.01 is doubl
rmcguire Wrote:
> why is this not a compiler bug?
> because:
> import std.stdio;
>
> void main() {
> float f=0.01;
> results in:
> 0.01->0
0.01 is double, there is type conversion there.
> writefln("%0.2f->%d",f,cast(int)(f*100f));
> results in:
> 0.01->1
f*100f is represente
Jarrett Billingsley Wrote:
> On Sat, Apr 11, 2009 at 5:33 AM, Kagamin wrote:
> > If "in" is equivalent to "scope const". What "scope" means? Does it mean
> > that this argument doesn't escape scope of this function? Then "const"
> > parameters are not quite equivalent to "in" parameters.
> >
>
I am using dmd v2.032 and trying to read int values from the standard input:
import std.cstream;
void main()
{
while (!din.eof()) {
int value;
din.readf(&value);
if (!din.eof()) {
dout.writefln("read: ", value);
}
}
}
1) If I
- start the prog
What is the simplest way of using a file?
There are two 'File's in Phobos and they conflict:
1) struct File in std.stdio
2) class File in std.stream
The one in std.stream.File is definitely what I want to use. What to do?
Prefer using full names in D as in std.stream.File?
Perhaps std.stdio is
Steven Schveighoffer Wrote:
> > int[] a = [ 0, 1, 2 ];
> > a[0] = 42;
> No, it's a mutable array. It's one of the quirks of D2 that bugs me. A
> string literal is an immutable array but a normal array literal actually
> allocates new space on the heap for the array every time you us
Don Wrote:
> > void main()
> > {
> > int[2] static_0 = [ 1, 1 ];
> > int[2] static_1 = [ 1:1 ];
> > }
> >
> > dmd: init.c:431: virtual Expression* ArrayInitializer::toExpression():
> > Assertion `j < edim' failed.
>
> I've added this to Bugzilla as bug 3246. With a patch .
Thank you fo
Lars T. Kyllingstad Wrote:
> I've tried with DMD 2.031, and I can't reproduce this. This works fine
> for me:
>
>int[2] static_0 = [ 1, 1 ]:
>int[2] static_1 = [ 1:1 ];
>
> Where did you put the declarations? I've tried putting them at both
> module level and in a class, and both times
Does the expression [ 0, 1, 2 ] form an immutable array? If so, is the
assignment to a[0] undefined below? Is it trying to modify an immutable element?
int[] a = [ 0, 1, 2 ];
a[0] = 42;
The reason for my thinking that [ 0, 1, 2] is an array is because it has the
.dup property and this w
The 'static' keyword is required by dmd 2.031 for the second of these two
definitions:
int[2] static_0 = [ 1, 1 ];
static int[2] static_1 = [ 1:1 ];
Is this inconsistency by design? Should 'static' be required for both or
neither?
Ali
I am trying to learn to read bool as a string and have it converted to bool.
Too much to ask? :)
This is what I know in C++:
#include
#include
using namespace std;
int main()
{
cin >> boolalpha;
cout << boolalpha;
bool b = false;
cin >> b;
cout << b << endl;
}
cin and c
17 matches
Mail list logo