How should i define the param type of console-log?

Your hoot project is just amazing! I enjoyed playing with it a lot!
And about the question, both the following define-foreign works for the given type, but is there a way to combine the string and extern type? :grinning_face_with_smiling_eyes:

(define-foreign console-log
“console” “log”
(ref extern) → none)

(define-foreign console-log
“console” “log”
(ref string) → none)

and How should i define a nested call like event.target.value, it seems that your project only use “xxx” “xxxx” format. :slight_smile:
And at last, your hoot is just awesome!

Hi! WebAssembly’s static type system is quite low-level and there is no polymorphism or overloading. So, there’s no way to combine your two define-foreign calls into one.

Thanks, Though it’s not a big problem, you still answer me with explanation :grinning_face_with_smiling_eyes:

If like me you were wiring up console for debugging, you may want to try the pk function in guile. It seems to just work at writing things to console in the current version of hoot, but I haven’t tested it extensively yet.

I just found out about it myself from Jessica Tallon’s fossdem talk on goblins (FOSDEM 2025 - Goblins: The framework for your next project!)

Note that while pk, display, write, etc. are great for inspecting Scheme values, they can’t help you inspect external values coming from JavaScript.

Maybe I’m not getting exactly what you’re saying but when I’m running my little hoot project locally and insert a (pk (get-value-by-id “my-div”)) it will just print that value to console?

display on the other hand is completely silent as of the current hoot version (used to just throw an error on the previous version I was using). I’m just finding out about write!

pk will print a representation of any Scheme value to the current output port, which by default is the console. In your example, the value is an external reference to a JS value and the printed representation will be simply #<external> as host values are opaque to the WASM guest.

Also, display is not silent. Likely you are not flushing the output port buffer with flush-output-port.