How do I truncate a file, delete bytes, or set the end of file from a
stream?
For example, what would be the easiest way to delete the last 4 bytes from
a file?
Do you know if in Phobos there is already a way to format a number with
thousands separators (a point, comma o underscore)?
Bye and thank you,
bearophile
Jonathan M Davis:
That would depend entirely on the optimizer.
You have to take a look at the asm produced by the compiler to be sure what its
optimizations have done.
Bye,
bearophile
Jonathan M Davis:
Certainly, once range propagation has been fully implemented, this particular
will work without needing any casts, but as soon as the compiler doesn't know
what the values of x and y are, I believe that it would still end up
complaining.
I am not sure D range propagation
On 2011-06-12 02:37, bearophile wrote:
Jonathan M Davis:
Certainly, once range propagation has been fully implemented, this
particular will work without needing any casts, but as soon as the
compiler doesn't know what the values of x and y are, I believe that it
would still end up
From the book I was under the impression that there could be user defined
attribute.
I wonder if this has been implemented?
My problem: I try to implement a simplistic DataContractSerializer (as in
Apparently std.string.format() is not implemented / does not compile! :(
Is there any sort of replacement?
Something which works like writefln() but output a string!
Lloyd Dupon:
Apparently std.string.format() is not implemented / does not compile! :(
This works for me, DMD 2.053:
import std.stdio, std.string;
void main() {
int x = 10;
auto s = format(%d, 10);
writeln(, s, );
}
Bye,
bearophile
mm... ok.
but why the line below doesn't compile?
mixin(format(class %s {}, A));
bearophile wrote in message news:it2pf5$1qh6$1...@digitalmars.com...
Apparently std.string.format() is not implemented / does not compile! :(
This works for me, DMD 2.053:
I'm using 2.053
this compile fine:
enum : string
{
A = hello,
B = betty,
}
this doesn't!
enum AA : string
{
A = hello,
B = betty,
}
Am I missing something? Named enum can't be typed? known bug?
I have a method like that:
===
public string repeat(string s, int num)
{
string result = s;
for (int i=1; inum; i++)
result ~= s;
return result;
}
===
basically it will create num string, each a little longer...
is there a more efficient way to go about that?
thanks! :)
On 6/12/11 6:37 PM, Lloyd Dupont wrote:
mm... ok.
but why the line below doesn't compile?
mixin(format(class %s {}, A));
Because format presumably can't be interpreted at compile time (yet) –
not all functions are necessarily CTFEable.
David
On Sun, 12 Jun 2011 12:49:25 -0400, Lloyd Dupont ld-rem...@galador.net
wrote:
I have a method like that:
===
public string repeat(string s, int num)
{
string result = s;
for (int i=1; inum; i++)
result ~= s;
return result;
}
===
basically it will create num string, each a
Jonathan M Davis wrote:
On 2011-06-12 02:37, bearophile wrote:
Jonathan M Davis:
Certainly, once range propagation has been fully implemented, this
particular will work without needing any casts, but as soon as the
compiler doesn't know what the values of x and y are, I believe that it
would
On 2011-06-12 10:30, David Nadlinger wrote:
On 6/12/11 6:37 PM, Lloyd Dupont wrote:
mm... ok.
but why the line below doesn't compile?
mixin(format(class %s {}, A));
Because format presumably can't be interpreted at compile time (yet) –
not all functions are necessarily CTFEable.
On 2011-06-12 11:08, Steven Schveighoffer wrote:
On Sun, 12 Jun 2011 12:49:25 -0400, Lloyd Dupont ld-rem...@galador.net
wrote:
I have a method like that:
===
public string repeat(string s, int num)
{
string result = s;
for (int i=1; inum; i++)
result ~=
Den 12-06-2011 15:43, Lloyd Dupont skrev:
From the book I was under the impression that there could be user
defined attribute.
I wonder if this has been implemented?
My problem: I try to implement a simplistic DataContractSerializer (as in
Den 12-06-2011 18:37, Lloyd Dupont skrev:
mm... ok.
but why the line below doesn't compile?
mixin(format(class %s {}, A));
Because the mixin is evaluated at compile time. This means that
format(...) is evaluated at compile time which afaik is not supported.
It may be supported in the
Lloyd Dupont wrote:
I'm using 2.053
this compile fine:
enum : string
{
A = hello,
B = betty,
}
this doesn't!
enum AA : string
{
A = hello,
B = betty,
}
Am I missing something? Named enum can't be typed? known bug?
It works just fine for me.
do you have DMD 2.053 on Windows?
Your code fail for me with:
main.d(10): Error: Integer constant expression expected instead of hello
main.d(11): Error: Integer constant expression expected instead of betty
main.d(10): Error: Integer constant expression expected instead of hello
main.d(11):
yep, the example is simple because it is an example!
Thanks for your suggestion! :)
Jonathan M Davis wrote in message
news:mailman.850.1307909499.14074.digitalmars-d-le...@puremagic.com...
On 2011-06-12 10:30, David Nadlinger wrote:
On 6/12/11 6:37 PM, Lloyd Dupont wrote:
mm... ok.
but
But... string being immutable I don't see the point of allocating some space
for one..
Am I missing something?
Steven Schveighoffer wrote in message
news:op.vwy503w4eav7ka@localhost.localdomain...
On Sun, 12 Jun 2011 12:49:25 -0400, Lloyd Dupont ld-rem...@galador.net
wrote:
I have a
I've got 2.053 and it works for me.
Thanks!
Jonathan M Davis wrote in message
news:mailman.851.1307909610.14074.digitalmars-d-
Also, std.string.repeat has been scheduled for deprecation. You should use
std.array.replicate instead. It does the same thing but for all arrays
instead
of just strings.
- Jonathan M Davis
On 2011-06-12 18:02, Lloyd Dupont wrote:
But... string being immutable I don't see the point of allocating some
space for one..
Am I missing something?
Just because it's immutable doesn't mean that it doesn't need to exist at
runtime. All immutable means is that you can't change it. It could
On Sun, 12 Jun 2011 21:02:05 -0400, Lloyd Dupont ld-rem...@galador.net
wrote:
But... string being immutable I don't see the point of allocating some
space for one..
Am I missing something?
Reserving space for appending does not make that space immutable, yet.
As far as the runtime is
Thanks Steven, that was very informative!
Steven Schveighoffer wrote in message
news:op.vwzrwdmteav7ka@localhost.localdomain...
On Sun, 12 Jun 2011 21:02:05 -0400, Lloyd Dupont ld-rem...@galador.net
wrote:
But... string being immutable I don't see the point of allocating some
space for
I have problem with Object
for example this doesn't compile:
===
Object o;
o = ;
===
with error: cannot implicitly convert expression () of type string to
object.Object
or this also failed to compile:
===
class Foo
{
public:
Object foo, bar, snafu;
override const bool opEquals(Object
On 2011-06-12 22:25, Lloyd Dupont wrote:
I have problem with Object
for example this doesn't compile:
===
Object o;
o = ;
===
with error: cannot implicitly convert expression () of type string to
object.Object
Object is the base class of all classes. Nothing which is not a class is an
On 2011-06-12 22:37, Jonathan M Davis wrote:
On 2011-06-12 22:25, Lloyd Dupont wrote:
I have problem with Object
for example this doesn't compile:
===
Object o;
o = ;
===
with error: cannot implicitly convert expression () of type string to
object.Object
Object is the base
30 matches
Mail list logo