Created
October 18, 2021 13:33
-
-
Save Metaxal/f6ac67013ba494b6911dc1696d19f0b8 to your computer and use it in GitHub Desktop.
Using quickscripts as normal racket modules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
(require quickscript-extra/scripts/provided-by ; exports the `provided-by` script, which is also a function | |
racket/class) | |
;; Create a mock class to avoid creating an actior editor% from the framework. | |
(define my-ed% | |
(class object% | |
(init-field string) | |
(define/public (get-start-position) 0) | |
(define/public (get-end-position) 0) | |
(define/public (get-backward-sexp start-pos) 0) | |
(define/public (get-forward-sexp start-pos) 0) | |
(define/public (get-text start end) string) | |
(super-new))) | |
(provided-by "" #:editor (new my-ed% [string "string-join"])) | |
(provided-by "" #:editor (new my-ed% [string "first"])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This example shows how a quickscript can be used entirely outside of DrRacket. There's no running dependency on racket/gui (nor on DrRacket). We can create a mock
editor%
class that just returns what the script needs [1].There are, however, installing dependencies on
quickscript
andquickscript-extra
, and the former has dependencies on DrRacket. [2][1] A better design of the script would provide an intermediate function that doesn't depend on the editor, but at least this example shows how to make it work even with a bad design.
[2] Possibly the core of quickscript could be extracted to an independent package
quickscript-core
, say, without an dependency on DrRacket.