3 ms·
Indeed. Is "let x = y+y" so bad? I wonder how much of the resistance owes to longer words like "local"/"define", or ugly abbrevs like "mut"/"var".
by abecedarius 9y ago
Indeed. Is "let x = y+y" so bad? I wonder how much of the resistance owes to longer words like "local"/"define", or ugly abbrevs like "mut"/"var".
- Pxtl 9y agoSo what would you use for declaring a variable that won't be assigned to until lower scope? Like a variable that will be assigned inside a try/catch block but needs to outlive it so it's declared before the try? Just let x ? That looks weird. Or we're back to "var". Or throwing another keyword at x? let x exist Also weird. I've often dreamed of a nice lua-like math with syntax aimed at being familiar to a first year college math student, and "let" is an obvious keyword for variable declaration, but unless you go pure functional you need to be able to pre-declare variables.
- abecedarius 9y agoI'd make try/catch an expression, not a statement, like in Lisp -- it'd still be "let x = try {...}...". I agree that 'var' for mutable bindings is a reasonable design. In E it's 'def' for immutable and 'var' for mutable, for instance; and you can also write just 'def x' and then 'bind x := 42' further down (with single-assignment semantics). But though that's nice to have, you can do all right without it; if there was just a single form of definition, with lexical scope, I'd still prefer it to Lua or Python's designs -- clearer and less error-prone and still concise.
- Pxtl 9y agoI'd use "set" instead of "bind" and be consistent that assignment leverages the vanilla equality operator (since we're already talking about that for "let") but yeah, it sounds like you've been thinking about the same stuff I have. It sounds like you've been pondering the same problems I have. In my case it's because I've been working on a rules-engine for scientists and currently we're using SQL for the rule language and some of the syntactic warts of SQL are tripping us up. I keep meaning to learn enough Racket Scheme to experiment with implementing such a language in macros.
- abecedarius 9y agoFWIW, Common Lisp's macro system is relatively simple. I've been meaning to check out http://beautifulracket.com/ http://beautifulracket.com/ sometime to learn about the Racket way. Maybe Datalog could make a cleaner base for your project? Just a random thought; bound to be lots more considerations. Yeah, I have a project right now too where these questions come up -- https://github.com/darius/squeam https://github.com/darius/squeam -- though it's not really ready for anyone.