Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WHILE is broken #17

Open
mulle-nat opened this issue Jan 4, 2023 · 0 comments
Open

WHILE is broken #17

mulle-nat opened this issue Jan 4, 2023 · 0 comments

Comments

@mulle-nat
Copy link

mulle-nat commented Jan 4, 2023

I am using the WIKI article, to write some cpp code. I found that

#define WHILE(pred, op, ...) \
    IF(pred(__VA_ARGS__)) \
    ( \
        OBSTRUCT(WHILE_INDIRECT) () \
        ( \
            pred, op, op(__VA_ARGS__) \
        ), \
        __VA_ARGS__ \
    )
#define WHILE_INDIRECT() WHILE

#define pred( ...)  0
#define xxx( i)     1

{
   EVAL( WHILE( pred, xxx, nothing))
}

produces

{
   nothing
}

Which I think is wrong, because pred is always 0.
If I change IF to WHEN things are better:

{
}

For me its virtually impossible to write a functioning while loop with WHILE. First there is no example to steal from and the way pred and op have to be coded (is it even possible ?) is very unclear. I tried but gave up and wrote my own LOOP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant