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

Part 5: Control flow clogged #393

Open
chuchana opened this issue Oct 12, 2024 · 5 comments
Open

Part 5: Control flow clogged #393

chuchana opened this issue Oct 12, 2024 · 5 comments

Comments

@chuchana
Copy link

When clicking, the printing doesn't seem to finish correctly, e.g. for this snippet:

(defun hello-private (body)
  "Create a div on new pages containing - hello world
That when clicked changes color."
  (set-on-click (create-div body :content "hello world")
                (lambda (obj)
                  (setf (color obj) (progn
                                      (terpri)
                                      (princ "Setting color to:")
                                      (print (rgb (random 255)
                                                  (random 255)
                                                  (random 255))))))))

Instead of

Setting color to:
"rgb(...)"

Setting color to:
"rgb(...)"

Setting color to:
"rgb(...)"

I get

Setting color to:

"rgb(...)"
Setting color to:

"rgb(...)"
Setting color to:

(empty lines added for clarity)


Since I could not imagine that I found a bug in progn, I searched the web for a while and found a similar problem and answer.

Adding (finish-output) to the function fixes the problem:

(defun hello-private (body)
  "Create a div on new pages containing - hello world
That when clicked changes color."
  (set-on-click (create-div body :content "hello world")
                (lambda (obj)
                  (setf (color obj) (progn
                                      (terpri)
                                      (princ "Setting color to:")
                                      (print (rgb (random 255)
                                                  (random 255)
                                                  (random 255)))
                                      (finish-output))))))

The same applies to the next variation of hello-private:

(defun hello-private (body)
  "Create a div on new pages containing - hello world
That when clicked changes color."
  (set-on-click (create-div body :content "CLICK ME TO PLAY")
                (lambda (obj)
                  (setf (color obj) (cond ((equal (random 10) 1)
                                           (setf (text obj) "--(O)-(O)--")
                                           (print "RED LIGHT!")
                                           (finish-output)
                                           (rgb 255 0 0))
                                          (t
                                           (setf (text obj) "--(X)-(X)--")
                                           (print "I'm not looking..")
                                           (finish-output)
                                           (rgb 0
                                                (random 255)
                                                (random 255))))))))
@bryce-carson
Copy link

"Clogged." I like that. Henceforth whenever a CLOG application is "bugged" in any way, we should refer to it as a "clogged pipe."

@aykaramba
Copy link
Contributor

Thanks for the heads up. Will make a mental note.

@rabbibotton
Copy link
Owner

"Clogged." I like that. Henceforth whenever a CLOG application is "bugged" in any way, we should refer to it as a "clogged pipe."

Is this a CLOG issue? It is a terminal buffering issue from what I see.

CLOG is not perfect, I wrote it after a few months of learning CL but it is being used successfully as the GUI in embedded systems, computer applications and on the web. The CLOG has been my not realizing the need to market CLOG as a new category of API to insure it is not thought of as a web framework.

I have been CLOGGED and have had a CLOG educational disorder dysfunction :)

I am working on redoing my marketing soon.

@bryce-carson
Copy link

"Clogged." I like that. Henceforth whenever a CLOG application is "bugged" in any way, we should refer to it as a "clogged pipe."

Is this a CLOG issue? It is a terminal buffering issue from what I see.

Not at all! I don't understand the issue's contents: I only thought the phrasing was an amusing pun.

CLOG is a venerable piece of software. It reminds me of R's Shiny.

@rabbibotton
Copy link
Owner

"CLOG is a venerable piece of software. It reminds me of R's Shiny."

The world is getting closer to GNOGA and CLOG, I hope have the time to work on the category branding in time to push: The best Embedded GUI platform - CLOG and Common Lisp :)

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

4 participants