p.s. faster weak typing solution is definitely possible if you'll narrow
possible type set. but as i said, i'd not recommend to go this way. there
can be dragon in the end.
signature.asc
Description: PGP signature
On 06/13/2015 11:12 PM, Ozan wrote:
> Hallo!
>
> Is it possible to create arrays which has more then one type,
Not possible.
> f. ex. array[0] = 1; array[1] = "z"; array[2] = new clazz(),
>
> I tried "Variant", but it slow down heavily my app.
Another option is OOP. Depending on the way t
On Sun, 14 Jun 2015 06:12:29 +, Ozan wrote:
> Hallo!
>
> Is it possible to create arrays which has more then one type,
> f. ex. array[0] = 1; array[1] = "z"; array[2] = new clazz(),
>
> I tried "Variant", but it slow down heavily my app.
it is possible. with Variant. ;-)
chances are t
Hallo!
Is it possible to create arrays which has more then one type,
f. ex. array[0] = 1; array[1] = "z"; array[2] = new clazz(),
I tried "Variant", but it slow down heavily my app.
Greetings,
Ozan
On Sat, 13 Jun 2015 23:55:53 +, JDemler wrote:
> After a bit of rethinking:
>
> I guess the compiler goes through 2 loops:
> the first resolves __traits, the second does ctfe.
>
> That would explain this behavior. "a" is not present to the compiler
> while it tries to resolve my __traits cal
oh, seems that i managed to make everything even less understandable...
signature.asc
Description: PGP signature
On Sun, 14 Jun 2015 05:11:17 +, Maxim Fomin wrote:
> On Sunday, 14 June 2015 at 01:20:39 UTC, Timothee Cour wrote:
>> I understand this is legal for declaration wo definition (void
>> fun(int);)
>> but why allow this:
>> void test(int){} ?
>
> Actually it is void test(int _param_0) { }
> You
On Sunday, 14 June 2015 at 01:20:39 UTC, Timothee Cour wrote:
I understand this is legal for declaration wo definition (void
fun(int);)
but why allow this:
void test(int){} ?
Actually it is void test(int _param_0) { }
You can test by compiling void test(int) { _param_0 = 0; }
Nameless paramet
On 14/06/2015 12:32 p.m., Adam D. Ruppe wrote:
On Friday, 12 June 2015 at 07:17:44 UTC, Jacob Carlborg wrote:
I'm running a OS X 10.7 on Macbook from 2006, it's working perfectly
fine. Although the whole computer it's quite slow, it only has 2 GB of
RAM.
Thanks everyone. A coworker says he is
On 6/13/15 6:45 AM, kerdemdemir wrote:
I have two strings(stringB,stringC) which I need to repeat(bCount times,
cCountTimes) and then chain.
auto charAppender = appender!(dchar[]);
auto totalStr = stringB.repeat(bCount).chain(stringC.repeat(cCount));
This compiles and works ok,
But when I try t
On Sunday, 14 June 2015 at 01:31:25 UTC, Adam D. Ruppe wrote:
On Sunday, 14 June 2015 at 00:52:20 UTC, FujiBar wrote:
I have read that in D structs are always allocated on the
stack while classes are always allocated on the heap.
That's not true; it is a really common misconception.
Putting a
On Sunday, 14 June 2015 at 00:52:20 UTC, FujiBar wrote:
I have read that in D structs are always allocated on the stack
while classes are always allocated on the heap.
That's not true; it is a really common misconception.
Putting a struct on the heap is trivial and built into the
language: `S
Sometimes you have empty functions and/or unused parameters just
to fulfill some interface but you don't actually care about the
arguments passed. No need to name them if you aren't going to use
them.
I understand this is legal for declaration wo definition (void fun(int);)
but why allow this:
void test(int){} ?
I have read that in D structs are always allocated on the stack
while classes are always allocated on the heap. Well, I often
have classes where I want some instances on the stack, some on
the heap. So.. what to do?
On Friday, 12 June 2015 at 07:17:44 UTC, Jacob Carlborg wrote:
I'm running a OS X 10.7 on Macbook from 2006, it's working
perfectly fine. Although the whole computer it's quite slow, it
only has 2 GB of RAM.
Thanks everyone. A coworker says he is selling an old Mac of his
from 2010 and it so
On Saturday, 13 June 2015 at 23:51:32 UTC, JDemler wrote:
I have another one :)
module test;
struct S{
string member1;
int member2;
}
string test(string[] a)
{
const S s = { member1:"It is also important to go to Mars!"};
const string y = a[0];
return y;
}
void main()
{
enum e = [
I have another one :)
module test;
struct S{
string member1;
int member2;
}
string test(string[] a)
{
const S s = { member1:"It is also important to go to Mars!"};
const string y = a[0];
return y;
}
void main()
{
enum e = ["member1","member2"];
pragma(msg, e[0]);
pragma(msg, te
On 06/13/2015 04:23 AM, Quentin Ladeveze wrote:
> The problem is that your appender is a char appender, and you try to put
> a dstring into it. Replace :
>
> charAppender.put(totalStr);
>
> by :
>
> foreach(elem; totalStr){
> charAppender.put(elem);
> }
>
> elem will be a dchar, so it will wo
On Saturday, 13 June 2015 at 08:52:59 UTC, John Colvin wrote:
perhaps:
class A
{
struct S
{
// ...
}
S s;
alias s this;
this(A rhs)
{
s = rhs.s;
}
}
I'm using this now, and it doesn't feel like a workaround too
much.
For something with 5 value
Are `foo` and `bar` always inlined?
struct S
{
pragma(inline, true):
void foo(T)(T t) {}
void bar(T)(T t) {}
}
On Saturday, 13 June 2015 at 19:13:20 UTC, Ilya Yaroshenko wrote:
Are `foo` and `bar` always inlined?
struct S
{
pragma(inline, true):
void foo(T)(T t) {}
void bar(T)(T t) {}
}
I am confused becuase they are templates.
On Saturday, 13 June 2015 at 18:15:30 UTC, Dennis Ritchie wrote:
Actually, I will file issue `std.conv` in Phobos to add such
specifications. It will suit me.
*specializations
On Saturday, 13 June 2015 at 17:39:25 UTC, Kagamin wrote:
Type is probably possible, though conversion method will be
simpler. You can even try to write a specialization of `to` for
multidimentional arrays if it doesn't work.
It appears the problem can be solved by creating specifications
.to
On Saturday, 13 June 2015 at 17:37:31 UTC, anonymous wrote:
Please show how it is not. Seems to work just fine.
OK. Still, this method works:
char[][][][][][] strArr = ["foo", "baz"], ["bar",
"tor".to!(char[][][][][])];
But I don't want to write this `.to!(char[][][][][])`.
On Satu
Is there an existing issue on issue.dlang.org? If not can you
report it
https://issues.dlang.org/show_bug.cgi?id=10376
On Saturday, 13 June 2015 at 17:02:06 UTC, Dennis Ritchie wrote:
On Saturday, 13 June 2015 at 16:20:46 UTC, anonymous wrote:
[...]
Yeah, that would be neat. But typing out ".dup" isn't that
bad, and converting a `string[]` to a `char[][]` is simple:
import std.conv: to;
auto a = ["foo"].to
Type is probably possible, though conversion method will be
simpler. You can even try to write a specialization of `to` for
multidimentional arrays if it doesn't work.
On Saturday, 13 June 2015 at 16:20:46 UTC, anonymous wrote:
Do you like to write?
char[][] strArray = ["foo".dup, "bar".dup, "baz".dup];
Ok. That's all you're on about? Basically you'd like this:
char[] s = "foo";
and this:
char[][] a = [["foo"]];
etc.
Yes. That's right, and not other
Oh, sorry, the error was in another place.
On Sat, 13 Jun 2015 12:20:40 -0400, ketmar wrote:
On Sat, 13 Jun 2015 13:49:49 +, anonymous wrote:
Taking it one step further:
template Version(string name)
{
mixin("
version("~name~") enum Version = true;
else enum Version = false;
");
}
static if(Version!"O
On Sat, 13 Jun 2015 13:49:49 +, anonymous wrote:
> Taking it one step further:
>
> template Version(string name)
> {
> mixin("
> version("~name~") enum Version = true;
> else enum Version = false;
> ");
> }
>
> static if(Version!"One" || Version!"Two")
> {
>
On Sat, 13 Jun 2015 12:01:29 -0400, bitwise wrote:
>> nope. Walter is against that, so we'll not have it, despite the
>> triviality of the patch.
>
> Any idea what the rationale was for not allowing it?
i don't remember. that murmuring about "it makes the code harder to read"
goes beyond me, so
On Saturday, 13 June 2015 at 15:58:44 UTC, Dennis Ritchie wrote:
On Saturday, 13 June 2015 at 15:45:34 UTC, anonymous wrote:
Before jumping to a solution, please elaborate on the
perceived problem. I have a feeling that there is none.
Do you like to write?
char[][] strArray = ["foo".dup, "bar"
On Saturday, 13 June 2015 at 16:09:58 UTC, Dennis Ritchie wrote:
On Saturday, 13 June 2015 at 15:45:34 UTC, anonymous wrote:
[...]
Are you saying that `string[]` is simpler than `char[][]`?
That's not true: `string` is an alias for `immutable(char)[]`,
so `string[]` is the same as `immutable(c
On Saturday, 13 June 2015 at 15:45:34 UTC, anonymous wrote:
Huh? You mean with string literals? That would be a rather
silly reason to avoid `char[]`. Please show an example of .dup
you'd like to avoid.
Yes, string literals.
I understand that the type of `string[]` to D is a simple data
type
Look like I am doing serialization wrong way:
struct DBFields
{
Date date;
string tag;
int popularity;
}
DBFields [] dbfields;
DBFields dbfield;
.
dbfields ~= dbfield;
writeln(serializeToJson(dbfields));
As result I am getting only first string.
[{"popularity":1,"tag":"webserver","date":"20
On Saturday, 13 June 2015 at 15:45:34 UTC, anonymous wrote:
Please show an example of .dup you'd like to avoid.
For example, if you need to create a five-dimensional array of
strings :)
On Sat, 13 Jun 2015 08:21:50 -0400, ketmar wrote:
On Fri, 12 Jun 2015 20:41:59 -0400, bitwise wrote:
Is there a way to compile for multiple conditions?
Tried all these:
version(One | Two){ }
version(One || Two){ }
version(One && Two){ }
version(One) | version(Two){ }
version(One) || versio
On Saturday, 13 June 2015 at 15:45:34 UTC, anonymous wrote:
Before jumping to a solution, please elaborate on the perceived
problem. I have a feeling that there is none.
Do you like to write?
char[][] strArray = ["foo".dup, "bar".dup, "baz".dup];
I suggest that such an option:
str[] strArray =
On Saturday, 13 June 2015 at 15:21:19 UTC, Dennis Ritchie wrote:
Hello, everyone!
I like to work with arrays of strings like `string[] strArray`,
but unfortunately, they are immutable.
I do not like to work with arrays of strings such as `char[][]
strArray`, because it is necessary to apply
On Friday, 12 June 2015 at 15:36:22 UTC, anonymous wrote:
no need for ~this() to modify immutable data:
class C {
int a;
this(int a) {
this.a = a;
}
}
struct S {
C elem = new C(42);
}
void main() {
import std.stdio;
immutable(S) s1;
On Saturday, 13 June 2015 at 15:21:19 UTC, Dennis Ritchie wrote:
I wish to propose the creation of new types of data D: str,
wstr, dstr, which will be the analogs of C++
`std::vector`.
Ie str, wstr, dstr be mutable counterparts immutable strings
respectively str (mutable(char[])), wstr (mutab
Hello, everyone!
I like to work with arrays of strings like `string[] strArray`,
but unfortunately, they are immutable.
I do not like to work with arrays of strings such as `char[][]
strArray`, because it is necessary to apply the method .dup each
substring to make them work :)
I understan
On Saturday, 13 June 2015 at 13:32:19 UTC, kerdemdemir wrote:
One more question I am asking those kind of questions to
understand and not ask same stuff over and over, :
auto totalStr = chain(stringB.replicate(bCount),
stringC.replicate(cCount));
writeln(typeof(totalStr.array()).stringof);
--
On Saturday, 13 June 2015 at 00:47:37 UTC, Mike Parker wrote:
// config.d
version(One) enum One = true;
else enum One = false;
version(Two) enum Two = true;
else enum Two = false;
// other.d
import config;
static if(One || Two) {
...
}
Taking it one step further:
template Version(string
On Saturday, 13 June 2015 at 13:32:19 UTC, kerdemdemir wrote:
Thanks lot that is really good.
One more question I am asking those kind of questions to
understand and not ask same stuff over and over, :
Don't worry, there is "learn" in "D.learn"
auto totalStr = chain(stringB.replicate(bCou
On Saturday, 13 June 2015 at 13:09:20 UTC, Dennis Ritchie wrote:
auto stringB = readln.chomp.map!(to!dchar).array;
auto stringC = readln.chomp.map!(to!dchar).array;
auto charAppender = appender!(dchar[][]);
auto totalStr = stringB.repeat(3).chain(stringC.repeat(5));
charAppender.put(totalStr)
On Saturday, 13 June 2015 at 13:01:29 UTC, kerdemdemir wrote:
Sorry to making the discussion longer and wasting your times.
But I am looking for a way without for loops. Also looping
every element one by one does not seems very efficient to me.
Any advices for that?
Maybe it fit?
auto strin
It is the same, but totalStr is not a dchar[]. It's a Result (a
type internal to the chain function ) which is a range. The
foreach loop iterates over Result, which returns dchar[].
So if you try to do something like that :
charAppender.put(totalStr.array), it won't work because
totalStr.arra
On Saturday, 13 June 2015 at 12:02:10 UTC, kerdemdemir wrote:
The problem is that your appender is a char appender, and you
try to put a dstring into it. Replace :
charAppender.put(totalStr);
by :
foreach(elem; totalStr){
charAppender.put(elem);
}
elem will be a dchar, so it will work.
On Fri, 12 Jun 2015 20:41:59 -0400, bitwise wrote:
> Is there a way to compile for multiple conditions?
>
> Tried all these:
>
> version(One | Two){ }
> version(One || Two){ }
> version(One && Two){ }
> version(One) | version(Two){ }
> version(One) || version(Two){ }
> version(One) && version(T
On Sat, 13 Jun 2015 10:36:39 +, John Colvin wrote:
> *for some reason it's not public, but it's very short and simple:
it's funny how many useful things are there in Phobos, carefully hidden
from user. i believe each D book should include an advice like this: "to
fully learn what you can do
The problem is that your appender is a char appender, and you
try to put a dstring into it. Replace :
charAppender.put(totalStr);
by :
foreach(elem; totalStr){
charAppender.put(elem);
}
elem will be a dchar, so it will work.
But I can see in the example of
array.appander(http://dlang
On Saturday, 13 June 2015 at 10:45:58 UTC, kerdemdemir wrote:
I have two strings(stringB,stringC) which I need to
repeat(bCount times, cCountTimes) and then chain.
auto charAppender = appender!(dchar[]);
auto totalStr =
stringB.repeat(bCount).chain(stringC.repeat(cCount));
This compiles and
I have two strings(stringB,stringC) which I need to repeat(bCount
times, cCountTimes) and then chain.
auto charAppender = appender!(dchar[]);
auto totalStr =
stringB.repeat(bCount).chain(stringC.repeat(cCount));
This compiles and works ok,
But when I try to append new string to charAppender :
On Saturday, 13 June 2015 at 10:01:45 UTC, JDemler wrote:
Hey,
i am trying to wrap my head around __traits.
One thing i just do not understand is following:
struct S{
string member1;
int member2;
}
void main(string[] args)
{
foreach(typeStr; __traits(allMembers, S))
{
auto tp
On Saturday, 13 June 2015 at 10:26:06 UTC, Marc Schütz wrote:
On Saturday, 13 June 2015 at 10:01:45 UTC, JDemler wrote:
Hey,
i am trying to wrap my head around __traits.
One thing i just do not understand is following:
struct S{
string member1;
int member2;
}
void main(string[] args)
{
On Saturday, 13 June 2015 at 10:01:45 UTC, JDemler wrote:
Hey,
i am trying to wrap my head around __traits.
One thing i just do not understand is following:
struct S{
string member1;
int member2;
}
void main(string[] args)
{
foreach(typeStr; __traits(allMembers, S))
{
auto tp
Hey,
i am trying to wrap my head around __traits.
One thing i just do not understand is following:
struct S{
string member1;
int member2;
}
void main(string[] args)
{
foreach(typeStr; __traits(allMembers, S))
{
auto tp = __traits(getMember, S, typeStr);
static if (__trait
On Saturday, 13 June 2015 at 05:20:42 UTC, SimonN wrote:
Hi,
I have a few classes with need for deeper copying. I don't want
a bitwise copy necessarily. Ideally, I'd implement this(this).
I've thought about changing them to struct. However, the type
feels much more like a D class than a D st
61 matches
Mail list logo