Xah Talk Show 2025-03-28 Ep636 emacs lisp, change bracket type, design of function arguments
change brackets


links
examples of define function
const xadd = ((x,y) => x+y); console.log( xadd(3,4) )
def xadd(x, y): """add 2 nums""" return x + y print( xadd(3, 4)) # 7
;; define a function (defun xadd (x y) "add 2 numbers" (+ x y)) ;; call the function (xadd 3 4) ;; 7 ;; HHHH------------------------------ ;; now in emacs lisp, ;; any function can be trivially turn into a command, ;; and user can call it by Meta-x (normally Alt+x) ;; you can do this by adding ;; (interactive) ;; right after the docstring (defun xadd3and4 () "add 2 numbers" (interactive) (insert (number-to-string (+ 3 4)))) ;; HHHH------------------------------ ;; there is a question, how do you pass the function argument ;; when you call it interactively ;; there are many ways ;; the simplest and naive way, is to simply promp user, ;; and put the args inside list inside interactive (defun xadd (x y) "add 2 numbers" (interactive (list 3 4)) (insert (number-to-string (+ x y)))) ;; here's is how to ask user for arguments (defun xadd (x y) "add 2 numbers" (interactive (list (read-number "enter first number:") (read-number "enter second number:"))) (insert (number-to-string (+ x y)))) ;; 10 ;; fantastic
design of the semantics of function's aruments
- one thing of concern, is
- the design of the semantics of function's aruments
- this applies to any language, python perl ruby js fsharp clojure haskell java PowerShell Wolfram language etc
- this is a very broad topic
- you need to learn and think about.
- Microsoft PowerShell function argument design guide
- https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions_advanced_parameters
design of the syntax of function's aruments
- the other thing, is the
- the design of the syntax of function's aruments
- this aspect, is usually just part of the programing language syntax
- you no need to worry about much
example of unix fuckup
here are illustrations of the complete unix fuckup in both the function argument semantics and syntax
ps auwwx ps -ef ls -al

