I'm trying to implement "printf" and I'm getting an error. The
smallest possible code to demonstrate the error is:
```
import core.stdc.stdio;
void print(T...)(string prompt, T args) {
// Suppose all 'args' are of type "string" for this example
ulong carg = 0;
for (ulong i = 0; i < args[c
On Monday, 20 December 2021 at 21:26:45 UTC, rempas wrote:
// Suppose all 'args' are of type "string" for this example
still use
foreach(arg; args)
and skip that index variable.
Here how i'd do, but i'm not sure how to keep track of the index
of the arguments, i forgot..
```D
import core.stdc.stdio: putc, stdout;
void print(T...)(string prompt, T args)
{
foreach (a; args)
{
alias A = typeof(a);
static if (is(A : string))
{
f
On Monday, 20 December 2021 at 21:49:59 UTC, Adam D Ruppe wrote:
still use
foreach(arg; args)
and skip that index variable.
I know I can use foreach ("static foreach" more specifically) but
I need to be able to get the index to choose a specific argument
because I want to do formatting (th
On Monday, 20 December 2021 at 22:02:02 UTC, russhy wrote:
Here how i'd do, but i'm not sure how to keep track of the
index of the arguments, i forgot..
```D
import core.stdc.stdio: putc, stdout;
void print(T...)(string prompt, T args)
{
foreach (a; args)
{
alias A = typeof(a);
On Tuesday, 21 December 2021 at 06:44:36 UTC, rempas wrote:
This will not do for me because I want to do formatted output
and I need the index. But thanks a lot for tying to help!
I'm not certain I understand, but won't `foreach (i, a; args) {
/* ... */ }` in his example do that?
As in, if y
On Tuesday, 21 December 2021 at 08:11:39 UTC, Anonymouse wrote:
I'm not certain I understand, but won't `foreach (i, a; args) {
/* ... */ }` in his example do that?
As in, if you necessarily must index `args` instead of using a
foreach variable,
```d
import core.stdc.stdio : putc, stdout;
On Tuesday, 21 December 2021 at 08:26:17 UTC, rempas wrote:
On Tuesday, 21 December 2021 at 08:11:39 UTC, Anonymouse wrote:
I'm not certain I understand, but won't `foreach (i, a; args)
{ /* ... */ }` in his example do that?
As in, if you necessarily must index `args` instead of using a
for
On Tuesday, 21 December 2021 at 08:42:35 UTC, vit wrote:
You can use switch + static foreach:
```d
import std.stdio;
//this print args in reverse order:
void print(T...)(string prompt, T args)
{
void print_arg(size_t index){
switch(index){
static
Please keep us updated, that'll be interesting to see how a pure
D printf would look like!
On Tuesday, 21 December 2021 at 15:42:59 UTC, russhy wrote:
Please keep us updated, that'll be interesting to see how a
pure D printf would look like!
Glad someone is interested! I'm actually planning to make a whole
library ;)
Check my
[thread](https://forum.dlang.org/thread/frjbgaymuxjqpe
On 12/21/21 4:28 AM, rempas wrote:
On Tuesday, 21 December 2021 at 08:42:35 UTC, vit wrote:
You can use switch + static foreach:
```d
import std.stdio;
//this print args in reverse order:
void print(T...)(string prompt, T args)
{
void print_arg(size_t index){
s
On Tuesday, 21 December 2021 at 17:33:09 UTC, Steven
Schveighoffer wrote:
The reason your original isn't working is that indexing a list
of differently-typed things cannot be done using a runtime
index.
I'd say that an inner function + static foreach + switch is the
best way to convert from
On Tuesday, 21 December 2021 at 15:42:59 UTC, russhy wrote:
Please keep us updated, that'll be interesting to see how a
pure D printf would look like!
It already exists, it's called std.format.write.formattedWrite,
in terms of which things like std.stdio.writef are implemented.
On Tuesday, 21 December 2021 at 18:51:38 UTC, Stanislav Blinov
wrote:
On Tuesday, 21 December 2021 at 15:42:59 UTC, russhy wrote:
Please keep us updated, that'll be interesting to see how a
pure D printf would look like!
It already exists, it's called std.format.write.formattedWrite,
in terms
On Tuesday, 21 December 2021 at 22:50:57 UTC, russhy wrote:
I took a look and to be honest, it's the same story as
everything in the STD, they try to do everything at the same
time, so they up end calling each other, you end up lost in
multiple 8k LOC modules, not understanding what the funct
sorry for intervening... :)
On Wednesday, 22 December 2021 at 08:17:03 UTC, rempas wrote:
No garbage collector, no exceptions
GOLDEN WORDS!!!
Yeah, Seriously D's developers and user really underestimate
the fact that the biggest percent of people not using D are
doing so because of the Garb
17 matches
Mail list logo