On Tue, Jul 22, 2014 at 02:47:51AM +, Vlad Levenfeld via
Digitalmars-d-learn wrote:
> On Monday, 21 July 2014 at 19:02:59 UTC, H. S. Teoh via Digitalmars-d-learn
> wrote:
> >functionality is desirable. Maybe we should rouse a racket on the
> >main D forum to either make staticIota public, or i
On Monday, 21 July 2014 at 19:02:59 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
functionality is desirable. Maybe we should rouse a racket on
the main D
forum to either make staticIota public, or implement static
foreach. ;-)
static switch would be so sick. I frequently find myself doing
s
On Monday, 21 July 2014 at 18:02:33 UTC, bearophile wrote:
Dicebot:
Probably most idiomatic D way is to use files _instead_ of
classes :)
It is a bit idealistic though and is not yet 100% feasible in
practice.
What's stopping it from being feasible?
Bye,
bearophile
Stuff like this :
http
On Monday, 21 July 2014 at 18:10:14 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
On Mon, Jul 21, 2014 at 12:55:34AM +0200, Daniel Gibson via
Digitalmars-d-learn wrote:
Hi,
I have a variadic templated function and want to call a C
varargs function.
I want to be able to pass static arrays, whic
On Mon, Jul 21, 2014 at 06:48:45PM +, bearophile via Digitalmars-d-learn
wrote:
> H. S. Teoh:
>
> >It's already in std.typecons.
>
> But it is not online yet?
[...]
Hmph. Apparently it is undocumented. :-/ It has been in Phobos since
last April, but was private until November when it becam
Am 21.07.2014 20:09, schrieb H. S. Teoh via Digitalmars-d-learn:
On Mon, Jul 21, 2014 at 06:36:04PM +0200, Daniel Gibson via Digitalmars-d-learn
wrote:
[...]
However, having something like staticIota in the stdlib would probably
make sense.
[...]
It's already in std.typecons.
(Admittedly, th
H. S. Teoh:
It's already in std.typecons.
But it is not online yet?
Bye,
bearophile
On Mon, Jul 21, 2014 at 06:36:04PM +0200, Daniel Gibson via Digitalmars-d-learn
wrote:
[...]
> However, having something like staticIota in the stdlib would probably
> make sense.
[...]
It's already in std.typecons.
(Admittedly, that's not exactly the most obvious place to look for it...)
T
-
On Mon, Jul 21, 2014 at 12:55:34AM +0200, Daniel Gibson via Digitalmars-d-learn
wrote:
> Hi,
> I have a variadic templated function and want to call a C varargs function.
> I want to be able to pass static arrays, which D2 passes by value and C by
> reference, so I'd like to automagically translat
Dicebot:
Probably most idiomatic D way is to use files _instead_ of
classes :)
It is a bit idealistic though and is not yet 100% feasible in
practice.
What's stopping it from being feasible?
Bye,
bearophile
Hi,
Thanks for your answers. I'll continue to code as I ussed to do,
and try to improve my style to have a better usage of the modules
(today i'm most one class per file, so I don't use the modules at
all).
Bye,
Matthieu
Am 21.07.2014 17:04, schrieb TheFlyingFiddle:
On Monday, 21 July 2014 at 01:42:58 UTC, Daniel Gibson wrote:
Am 21.07.2014 03:34, schrieb Vlad Levenfeld:
To get a foreach to run at compile-time, you have to give it something
whose value is known to the compiler (so, T and typeof(argTuple) would
Probably most idiomatic D way is to use files _instead_ of
classes :)
It is a bit idealistic though and is not yet 100% feasible in
practice.
Matthieu:
Thanks for your answers. I'll continue to code as I ussed to do,
and try to improve my style to have a better usage of the
modules
(today i'm most one class per file, so I don't use the modules
at all).
Also, try to use less classes and more free (pure) functions :-)
This means a
On Monday, 21 July 2014 at 01:42:58 UTC, Daniel Gibson wrote:
Am 21.07.2014 03:34, schrieb Vlad Levenfeld:
To get a foreach to run at compile-time, you have to give it
something
whose value is known to the compiler (so, T and
typeof(argTuple) would
suffice, and 0..T.length really should as wel
On Monday, 21 July 2014 at 15:04:14 UTC, TheFlyingFiddle wrote:
//Outputs 1 to 10 at compile-time.
Edit: 0 to 9
On Sunday, 20 July 2014 at 16:35:52 UTC, Eric wrote:
There are a lot of discussions in the forums about how @property
should or could be implemented. But I can't seem to find
anything
that explains why or when I should use @property with the
current
compiler. Can anyone explain why and when I
On Sunday, 20 July 2014 at 18:14:29 UTC, Eric wrote:
Use @property when you want a pseudo-variable or something
that might be conceptually considered a "property" of the
object, i.e. to do this:
auto blah = thing.someProperty;
thing.someProperty = blahblah;
This is basically what I suspec
On Monday, 21 July 2014 at 15:04:14 UTC, TheFlyingFiddle wrote:
template staticIota(size_t s, size_t e, size_t step = 1)
{
import std.typetuple : TypeTuple;
static if(s < e)
alias staticIota = TypeTuple!(s, staticIota!(s + step, e,
step));
else
alias staticIota = TypeTuple!
On Sunday, 20 July 2014 at 18:14:29 UTC, Eric wrote:
Use @property when you want a pseudo-variable or something
that might be conceptually considered a "property" of the
object, i.e. to do this:
auto blah = thing.someProperty;
thing.someProperty = blahblah;
This is basically what I suspec
On Sunday, 20 July 2014 at 17:50:10 UTC, Nicolas Sicard wrote:
On Sunday, 20 July 2014 at 15:02:58 UTC, Foo wrote:
On Sunday, 20 July 2014 at 14:55:00 UTC, Foo wrote:
For clarification: how would that work without mixin + string?
I tried this:
mixin template Vala2(uint count, alias arr) {
Am 21.07.2014 03:05, schrieb Vlad Levenfeld:
Thats real weird that it would reject your "i" variable, given that
T.length is known at compile time. I think this is a bug. I can get your
code to compile if I change your foreach loop to this:
foreach(i, U; T)
modTuple[i] = transTupleElem(argTu
On 7/21/2014 3:14 AM, Eric wrote:
Use @property when you want a pseudo-variable or something that might
be conceptually considered a "property" of the object, i.e. to do this:
auto blah = thing.someProperty;
thing.someProperty = blahblah;
This is basically what I suspected. But why
write:
On 7/21/2014 7:13 AM, Matthieu wrote:
Hi!
I can't find any good tutorial about how to split my source code
in modules and packages. I don't want to use a Java splitting
style (one class per file) or something like that, I want to use
the D way, but it's so hard to find it! Can someone explain to
Am 21.07.2014 03:34, schrieb Vlad Levenfeld:
You're very welcome. The reason foreach(int i, x; argTuple) failed is
because argTuple is a value (of type T), and so known only at run-time.
Hmm but the only thing the compiler would need to know at compile-time
is still i, which only depends on a
On Monday, 21 July 2014 at 01:29:40 UTC, Daniel Gibson wrote:
Am 21.07.2014 03:05, schrieb Vlad Levenfeld:
Thats real weird that it would reject your "i" variable, given
that
T.length is known at compile time. I think this is a bug. I
can get your
code to compile if I change your foreach loop
Thats real weird that it would reject your "i" variable, given
that T.length is known at compile time. I think this is a bug. I
can get your code to compile if I change your foreach loop to
this:
foreach(i, U; T)
modTuple[i] = transTupleElem(argTuple[i]); // ok
On Sunday, 20 July 2014 at 15:45:37 UTC, Atila Neves wrote:
On Thursday, 17 July 2014 at 22:52:37 UTC, Justin Whear wrote:
On Thu, 17 Jul 2014 22:49:30 +, Nordlöw wrote:
AFAIK there is no compile-time variant of interfaces right?
Why is that?
Wouldn't it be nice to say something like
Hi,
I have a variadic templated function and want to call a C varargs
function. I want to be able to pass static arrays, which D2 passes by
value and C by reference, so I'd like to automagically translate those
arguments.
My idea was something like this:
extern (C) origFun(int x, ...);
Matthieu:
Can someone explain to me how to do it well, please?
Put related stuff in a module, and unrelated stuff in other
modules. If the module grows too much, split it up in two or
more. It's about the same as in Python. Just remember that
classes can see each other private members only
Hi!
I can't find any good tutorial about how to split my source code
in modules and packages. I don't want to use a Java splitting
style (one class per file) or something like that, I want to use
the D way, but it's so hard to find it! Can someone explain to me
how to do it well, please?
In the
I see these rules but when I compile following code and it
fails with error it looks VERY stupid.
import std.stdio;
void main()
{
ubyte a = 15;
ubyte b = 10;
ubyte c = a + b; //What is happening there?! ARGH! Are you
joking?!
}
Compilation output:
/d837
On Sunday, 20 July 2014 at 16:35:52 UTC, Eric wrote:
There are a lot of discussions in the forums about how @property
should or could be implemented. But I can't seem to find
anything
that explains why or when I should use @property with the
current
compiler. Can anyone explain why and when
Also, there is std.array.array for the ranges you want to convert
to arrays.
For example, if "a" is an array, "a.map!(x => x * 2).array"
produces an new array of doubled values (as opposed to a lazy
range produced by std.algorithm.map).
On 07/20/2014 11:14 AM, Eric wrote:
>
>> Use @property when you want a pseudo-variable or something that might
>> be conceptually considered a "property" of the object, i.e. to do this:
>>
>> auto blah = thing.someProperty;
>> thing.someProperty = blahblah;
>
> This is basically what I suspected.
On Sunday, 20 July 2014 at 15:54:15 UTC, bearophile wrote:
mixin template Vala2(uint count, alias arr) {
What about disallowing "mixin templatename" unless you add
"mixin" before the "template" keyword?
Bye,
bearophile
I thought it's disallowed.
On Sunday, 20 July 2014 at 15:02:58 UTC, Foo wrote:
On Sunday, 20 July 2014 at 14:55:00 UTC, Foo wrote:
For clarification: how would that work without mixin + string?
I tried this:
mixin template Vala2(uint count, alias arr) {
asm {
sub ESP, count;
mov
Uranuz:
ubyte a = 15;
ubyte b = 10;
ubyte c = a + b; //What is happening there?! ARGH! Are you
joking?!
In C/C++/D if you sum a types that are smaller than int, you
obtain an int. D has copied C for backwards compatibility with C
code.
Bye,
bearophile
On Sunday, 20 July 2014 at 16:35:52 UTC, Eric wrote:
There are a lot of discussions in the forums about how @property
should or could be implemented. But I can't seem to find
anything
that explains why or when I should use @property with the
current
compiler. Can anyone explain why and when
In C/C++/D if you sum a types that are smaller than int, you
obtain an int. D has copied C for backwards compatibility with
C code.
Bye,
bearophile
Is there any reasoning why this should remain unchainged? How
could it break interface between languages? And also this code
succesfully comp
On Sunday, 20 July 2014 at 16:47:30 UTC, Uranuz wrote:
Where did you get it? Or you compiled it yourself?
I'm building it myself. It's not difficult, when you know basic
git. And it doesn't take long. You can find instructions here:
http://wiki.dlang.org/Building_DMD
Because I tried beta4 and
On Sunday, 20 July 2014 at 17:59:07 UTC, John Colvin wrote:
On Sunday, 20 July 2014 at 16:35:52 UTC, Eric wrote:
There are a lot of discussions in the forums about how
@property
should or could be implemented. But I can't seem to find
anything
that explains why or when I should use @property
Use @property when you want a pseudo-variable or something that
might be conceptually considered a "property" of the object,
i.e. to do this:
auto blah = thing.someProperty;
thing.someProperty = blahblah;
This is basically what I suspected. But why
write:
@property int getValue() { retur
On Monday, 23 June 2014 at 18:32:38 UTC, Steven Schveighoffer
wrote:
On Sun, 22 Jun 2014 08:23:45 -0400, Uranuz
wrote:
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.
See integer promotion rule
Foo:
I do not understand?
Sorry, mine was a language design question (to catch your bug).
Bye,
bearophile
There are a lot of discussions in the forums about how @property
should or could be implemented. But I can't seem to find anything
that explains why or when I should use @property with the current
compiler. Can anyone explain why and when I should use the
@property tag?
Thx.
Eric
On Sunday, 20 July 2014 at 16:12:20 UTC, anonymous wrote:
On Sunday, 20 July 2014 at 15:48:19 UTC, Uranuz wrote:
Sorry, but this example doesn't work too.
Ugh, 2.065 doesn't like it, but it works for me with git head
(v2.066-devel-82b031c).
Where did you get it? Or you compiled it yourself?
I find myself writing this code too much and i'm curious what D
idiom I am missing.
given a list of files (or any strings) and then maybe I want to
sort them and maybe I don't.
string [] fileList;
... fill list
if (sort) {
string [] tempList;
foreach(filename;
On Sunday, 20 July 2014 at 15:48:19 UTC, Uranuz wrote:
Sorry, but this example doesn't work too.
Ugh, 2.065 doesn't like it, but it works for me with git head
(v2.066-devel-82b031c).
Sorry, somehow this submitted in the middle, even without the
captcha.
Please see the later version.
On Sunday, 20 July 2014 at 16:11:03 UTC, John Colvin wrote:
Even without ranges, you can do this:
string [] fileList;
... fill list
if (sort)
sort(fileList);
foreach(filename, fileList) {
... do something;
}
because sort works in-place.
Oh
On Sunday, 20 July 2014 at 15:54:15 UTC, bearophile wrote:
mixin template Vala2(uint count, alias arr) {
What about disallowing "mixin templatename" unless you add
"mixin" before the "template" keyword?
Bye,
bearophile
I do not understand?
On Sunday, 20 July 2014 at 16:02:05 UTC, Bob Tolbert wrote:
I find myself writing this code too much and i'm curious what D
idiom I am missing.
given a list of files (or any strings) and then maybe I want to
sort them and maybe I don't.
string [] fileList;
... fill list
if (sor
On Sunday, 20 July 2014 at 12:48:09 UTC, anonymous wrote:
import std.stdio;
interface IBase
{
template getStr(string fieldName)
{
final string getStr()
{
return "George";
}
}
I find myself writing this code too much and i'm curious what D
idiom I am missing.
given a list of files (or any string) and then maybe I want to
sort them and maybe I don't.
string [] fileList;
... fill list
if (sort) {
mixin template Vala2(uint count, alias arr) {
What about disallowing "mixin templatename" unless you add
"mixin" before the "template" keyword?
Bye,
bearophile
On Thursday, 17 July 2014 at 22:52:37 UTC, Justin Whear wrote:
On Thu, 17 Jul 2014 22:49:30 +, Nordlöw wrote:
AFAIK there is no compile-time variant of interfaces right?
Why is that?
Wouldn't it be nice to say something like
struct SomeRange realize InputRange {
/* implemen
Foo:
Hey guys. Can someone explain me, why this code does only works
with the inline assembler version but not with the mixin?
You need mixin(), it's unfortunate this gives no error messages:
import std.string: format;
enum Vala(uint count, alias arr) = format("
asm {
sub ESP, %
Foo:
It seems that your code doesn't work with 2.065.
Right. For 2.065 you have to replace the enum expression with a
template.
If you can I suggest to update your compiler to the latest beta.
There are tons of bugfixes and changes.
Bye,
bearophile
On Sunday, 20 July 2014 at 14:18:58 UTC, Foo wrote:
template Vala(uint count, alias arr) {
immutable string c = to!string(count);
enum Vala = "asm { sub ESP, " ~ c ~ "; mov " ~ arr.stringof ~
",
" ~ c ~ "; mov " ~ arr.stringof ~ " + 4, ESP; }";
}
...
mixin Vala!(1000,
On Sunday, 20 July 2014 at 14:55:00 UTC, Foo wrote:
For clarification: how would that work without mixin + string?
I tried this:
mixin template Vala2(uint count, alias arr) {
asm {
sub ESP, count;
mov arr, count;
mov arr + 4, ESP;
On Sunday, 20 July 2014 at 14:46:32 UTC, bearophile wrote:
enum Vala(uint count, alias arr) = format("
asm {
sub ESP, %d; // Reserve 'count' bytes
mov %s, %d; // Set a.length = 'count'
mov %s + 4, ESP; // Set &a[0] to reserved bytes
}", count, arr.stringof, cou
On Sunday, 20 July 2014 at 14:44:07 UTC, sigod wrote:
On Sunday, 20 July 2014 at 14:18:58 UTC, Foo wrote:
template Vala(uint count, alias arr) {
immutable string c = to!string(count);
enum Vala = "asm { sub ESP, " ~ c ~ "; mov " ~ arr.stringof ~
",
" ~ c ~ "; mov " ~ arr.stringof ~ "
sigod:
, but I see few mistakes in your code:
What's unfortunate is the silence of the compiler about that
programmer mistake :-)
Bye,
bearophile
enum Vala(uint count, alias arr) = format("
asm {
sub ESP, %d; // Reserve 'count' bytes
mov %s, %d; // Set a.length = 'count'
mov %s + 4, ESP; // Set &a[0] to reserved bytes
}", count, arr.stringof, count, arr.stringof);
I'd like to write that more like t
For clarification: how would that work without mixin + string?
Hey guys. Can someone explain me, why this code does only works
with the inline assembler version but not with the mixin?
Thanks in advance!
Code:
import std.stdio : writeln;
import std.conv : to;
template Vala(uint count, alias arr) {
immutable string c = to!string(count);
enum
67 matches
Mail list logo