How to Create a Language Evaluator
Add support for new programming languages in BonitoBook by creating a custom language evaluator.
Implementation
Create an extension module that defines:
Evaluator struct inheriting from
LanguageEvaleval_code method that executes code
getlanguageevaluator function that returns the evaluator
Example: Shell Evaluator
Register Language
Add your language to ALL_LANGUAGES in src/BonitoBook.jl:
Real Example: Python
The Python evaluator shows the full pattern:
Key Points
Extension loading: BonitoBook uses
Base.get_extension()to load evaluatorsThread safety: Code runs in
spawnat(1)for thread safety (e.g. for PythonCall)Variable sharing: Transfer variables between language and Julia using the
modparameterError handling: Wrap execution in try-catch, BonitoBook handles display
That's it! The AsyncRunner handles the rest automatically.