Thread overview | |||||
---|---|---|---|---|---|
|
October 14, 2010 writing | ||||
---|---|---|---|---|
| ||||
Hello, write and writeln just write; writef and writefln first format: seems clear. But the latter do not work properly with D strings, and the former do not work without format. Is there a practical way to just write anything to the terminal (without caring of its type)? Is there some rationale about this? Would it be possible to automatically add \0 to D strings passed to write/writeln (can a programmer define a custom func doing this before delegating to builtin funcs, or is it necessarily a job for the compiler?)? And/or what about having writef/writefln use "%s" as default format (when the first arg is not a string)? Denis -- -- -- -- -- -- -- vit esse estrany ☣ spir.wikidot.com |
October 14, 2010 Re: writing | ||||
---|---|---|---|---|
| ||||
Posted in reply to spir | On Thu, 14 Oct 2010 09:58:36 +0200, spir wrote:
> Hello,
>
> write and writeln just write; writef and writefln first format: seems clear. But the latter do not work properly with D strings, and the former do not work without format. Is there a practical way to just write anything to the terminal (without caring of its type)?
>
> Is there some rationale about this?
> Would it be possible to automatically add \0 to D strings passed to
> write/writeln (can a programmer define a custom func doing this before
> delegating to builtin funcs, or is it necessarily a job for the
> compiler?)? And/or what about having writef/writefln use "%s" as default
> format (when the first arg is not a string)?
I don't understand what you mean. This works just fine:
import std.stdio;
void main()
{
string s = "Hello world!";
writeln(s);
}
If I'm misunderstanding you, please explain, or perhaps give a code example.
-Lars
|
October 14, 2010 Re: writing | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars T. Kyllingstad | On Thu, 14 Oct 2010 08:05:09 +0000 (UTC)
"Lars T. Kyllingstad" <public@kyllingen.NOSPAMnet> wrote:
> On Thu, 14 Oct 2010 09:58:36 +0200, spir wrote:
>
> > Hello,
> >
> > write and writeln just write; writef and writefln first format: seems clear. But the latter do not work properly with D strings, and the former do not work without format. Is there a practical way to just write anything to the terminal (without caring of its type)?
> >
> > Is there some rationale about this?
> > Would it be possible to automatically add \0 to D strings passed to
> > write/writeln (can a programmer define a custom func doing this before
> > delegating to builtin funcs, or is it necessarily a job for the
> > compiler?)? And/or what about having writef/writefln use "%s" as default
> > format (when the first arg is not a string)?
>
>
> I don't understand what you mean. This works just fine:
>
> import std.stdio;
>
> void main()
> {
> string s = "Hello world!";
> writeln(s);
> }
>
> If I'm misunderstanding you, please explain, or perhaps give a code example.
>
> -Lars
Sorry, seems I just mistake the various C & D ways of coping with strings (too many forms of char arrays and functions that deal with them). I'll just stick with D funcs.
Denis
-- -- -- -- -- -- --
vit esse estrany ☣
spir.wikidot.com
|
Copyright © 1999-2021 by the D Language Foundation