I have tried this but i get an error saying:
C:\DMD\SAMPLES\BASE.D(15): incompatible types for ((cast(int)(a)) ~ (str)):
'int' and 'char[]'
it appears that a char is always casted as an integer and that
there is not a concatenation operator for chars and char arrays.
Should I just make a function to do this?
"Jonathan Andrew" <Jonathan_member pathlink.com> wrote in message
news:b9lab4$1uko$1 digitaldaemon.com...

This most obviously cannot work.
I would expect something like "a = [c] ~ a" to work, but it won't either!
IIRC it is possible to write "c ~= a" (isn't it in the Pavel's "stack
trick" example?), but hey, it doesn't make anything better! it's just an
exception form the rule: it simply complicates the language! Why is it
better that "c ~= [a]"? In fact, it's worse!
There has to be a possibility to define arrays on-the-go. Why is "int[]
ar = [1,2,3]" valid as a global, yet invalid as a local? Because you
cannot define arrays in-line. For what reason, actually? This is why you
stick to var-args functions: because you cannot compose an array at the
time of a function call. If you could, you wouldn't need them at all.
These are kind of things i'm sick of in D.
-i.

I have complained about the very selfsame thing, recently. I hope our words
do not fall upon deaf ears.
I realize that D tries to move all "static" work into one place, such that
the compiler doesn't allow you to declare stuff that works at the static, or
module, scope, in a function. Also it won't allow direct initialization of
array local variables, either, because that would end up generating code at
the start of the function?
So what if the compiler generates code for something, does it at init time,
so long as the semantics work out right. But I can't stand having to hop
back to module scope to do things that should be possible in local scope.
And I really hate having to declare temporary named variables to specify
something that should be possible to specify as a literal.
You should be able to construct an array at any time, anywhere an array
expression is possible. For instance, this should work:
char[] foo = { 'a', 'b', 'c' };
so should this:
char a,b,c;
char[] garbage = { a, b, c };
And so should this:
void foo(char[]);
int main()
{
foo( { 'd', argv[1][0], 'e' } );
return 0;
}
And ideally if I did this it'd work:
template foo(int i)
{
struct bar { const int value = i }
}
void work()
{
const int[] which = { 1, 2 };
const int first = instance foo(which[0]).bar.value;
const int second = instance foo(which[1]).bar.value;
}
I just don't want D to be a PITA to use. Plain and simple. The less
special cases, the better.
Sean
"Ilya Minkov" <midiclub 8ung.at> wrote in message
news:b9p1hn$2pa3$1 digitaldaemon.com...

Walter, i can see signs of a great omission!!!
Jonathan Andrew wrote:

a = c ~ a;

This most obviously cannot work.
I would expect something like "a = [c] ~ a" to work, but it won't either!
IIRC it is possible to write "c ~= a" (isn't it in the Pavel's "stack
trick" example?), but hey, it doesn't make anything better! it's just an
exception form the rule: it simply complicates the language! Why is it
better that "c ~= [a]"? In fact, it's worse!
There has to be a possibility to define arrays on-the-go. Why is "int[]
ar = [1,2,3]" valid as a global, yet invalid as a local? Because you
cannot define arrays in-line. For what reason, actually? This is why you
stick to var-args functions: because you cannot compose an array at the
time of a function call. If you could, you wouldn't need them at all.
These are kind of things i'm sick of in D.