Liste des Groupes | Revenir à cl c |
On 2025-04-04, Kaz Kylheku <643-408-1753@kylheku.com> wrote:On 2025-04-04, Thiago Adams <thiago.adams@gmail.com> wrote:>What do you think of this control block?>
>
do
{
FILE f = fopen("file.txt", "r");
>
if (f == NULL) quit; /*goes to else part*/
>
/*success here*/
for (int i =0; i < 10; i++){
...
if (error) quit;
}
>
}
else
{
/*some error*/
}
>
The else part might need access to some local variables
in the main part.
>
do {
char *name = calculate_path(PATH_PREFIX "/", name, ".txt");
FILE *f = fopen(...)
>
if (!f)
quit;
...
}
else
{
printf("unable to open %s\n", name);
...
}
>
If you make that work, you're creating scope wormholes between
disjoint curly braces, which is not allowed if youre name isn't
Bjarne Stroustrup.
How about: do/else if/else if/else with argument passing to first
clause whose signature can take the argument list:
>
do {
...
quit("rage"); // goes to (char *arg)
...
quit(42); // goes to (int arg)
...
}
else if (char *arg) // or just else? multiple elses on do, why not.
{
}
else (int arg)
{
}
>
Friday `f`noons, eh?
Les messages affichés proviennent d'usenet.