Copyright (C) 2000-2012 |
GNU Info (guile.info)Transforming Scheme name to C nameTransforming Scheme name to C name ================================== Normally, the name of a C function can be derived given its Scheme name, using some simple textual transformations: * Replace `-' (hyphen) with `_' (underscore). * Replace `?' (question mark) with "_p". * Replace `!' (exclamation point) with "_x". * Replace internal `->' with "_to_". * Replace `<=' (less than or equal) with "_leq". * Replace `>=' (greater than or equal) with "_geq". * Replace `<' (less than) with "_less". * Replace `>' (greater than) with "_gr". * Replace `@' with "at". [Omit?] * Prefix with "gh_" (or "scm_" if you are ignoring the gh interface). * [Anything else? -ttn, 2000/01/16 15:17:28] Here is an Emacs Lisp command that prompts for a Scheme function name and inserts the corresponding C function name into the buffer. (defun insert-scheme-to-C (name &optional use-gh) "Transforms Scheme NAME, a string, to its C counterpart, and inserts it. Prefix arg non-nil means use \"gh_\" prefix, otherwise use \"scm_\" prefix." (interactive "sScheme name: \nP") (let ((transforms '(("-" . "_") ("?" . "_p") ("!" . "_x") ("->" . "_to_") ("<=" . "_leq") (">=" . "_geq") ("<" . "_less") (">" . "_gr") ("." "at")))) (while transforms (let ((trigger (concat "\\(.*\\)" (regexp-quote (caar transforms)) "\\(.*\\)")) (sub (cdar transforms)) (m nil)) (while (setq m (string-match trigger name)) (setq name (concat (match-string 1 name) sub (match-string 2 name))))) (setq transforms (cdr transforms)))) (insert (if use-gh "gh_" "scm_") name)) automatically generated by info2www version 1.2.2.9 |