Closed evincarofautumn closed 9 years ago
I like it.
On Fri, Oct 10, 2014 at 7:36 PM, Jon Purdy notifications@github.com wrote:
This is part of a general effort to make Kitten’s syntax more ergonomic and consistent. Anyone want to voice objections? It’s longer, but I also don’t see a reason to have gratuitously abbreviated keywords like Rust, and the only language that Sam Developer has seen with def is Python, which
could be a false friend.
You can merge this Pull Request by running
git pull https://github.com/evincarofautumn/kitten def-define
Or view, comment on, or merge it at:
https://github.com/evincarofautumn/kitten/pull/134 Commit Summary
- Rename 'def' to 'define'.
File Changes
- M examples/beer.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-0 (12)
- M examples/brainfuck.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-1 (32)
- M examples/tictactoe.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-2 (50)
- M lib/Kitten/Parse.hs https://github.com/evincarofautumn/kitten/pull/134/files#diff-3 (2)
- M lib/Kitten/Tokenize.hs https://github.com/evincarofautumn/kitten/pull/134/files#diff-4 (2)
- M lib/Kitten/Types.hs https://github.com/evincarofautumn/kitten/pull/134/files#diff-5 (6)
- M lib/Prelude_Choice.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-6 (20)
- M lib/Prelude_Control.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-7 (36)
- M lib/Prelude_Convert.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-8 (4)
- M lib/Prelude_Exit.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-9 (4)
- M lib/Prelude_Function.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-10 (16)
- M lib/Prelude_IO.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-11 (58)
- M lib/Prelude_Math.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-12 (138)
- M lib/Prelude_Option.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-13 (20)
- M lib/Prelude_Range.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-14 (14)
- M lib/Prelude_Read.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-15 (2)
- M lib/Prelude_Stack.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-16 (8)
- M lib/Prelude_Stream.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-17 (24)
- M lib/Prelude_String.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-18 (30)
- M lib/Prelude_Tuple.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-19 (20)
- M lib/Prelude_Vector.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-20 (148)
- M syntax/kitten-mode.el https://github.com/evincarofautumn/kitten/pull/134/files#diff-21 (2)
- M test/Imported.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-22 (2)
- M test/Test/Term.hs https://github.com/evincarofautumn/kitten/pull/134/files#diff-23 (12)
- M test/Test/Token.hs https://github.com/evincarofautumn/kitten/pull/134/files#diff-24 (16)
- M test/abs.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-25 (2)
- M test/cartesian.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-26 (2)
- M test/choice.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-27 (4)
- M test/cond.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-28 (2)
- M test/currying.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-29 (8)
- M test/def-missing-block.err.expect https://github.com/evincarofautumn/kitten/pull/134/files#diff-30 (4)
- M test/def-missing-block.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-31 (2)
- M test/def-missing-name-block.err.expect https://github.com/evincarofautumn/kitten/pull/134/files#diff-32 (4)
- M test/def-missing-name-block.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-33 (2)
- M test/def-missing-name.err.expect https://github.com/evincarofautumn/kitten/pull/134/files#diff-34 (4)
- M test/def-missing-name.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-35 (2)
- M test/generalization.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-36 (4)
- M test/if.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-37 (4)
- M test/instance-checks-1.err.expect https://github.com/evincarofautumn/kitten/pull/134/files#diff-38 (6)
- M test/instance-checks-1.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-39 (2)
- M test/instance-checks-10.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-40 (4)
- M test/instance-checks-2.err.expect https://github.com/evincarofautumn/kitten/pull/134/files#diff-41 (6)
- M test/instance-checks-2.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-42 (2)
- M test/instance-checks-3.err.expect https://github.com/evincarofautumn/kitten/pull/134/files#diff-43 (10)
- M test/instance-checks-3.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-44 (2)
- M test/instance-checks-4.err.expect https://github.com/evincarofautumn/kitten/pull/134/files#diff-45 (6)
- M test/instance-checks-4.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-46 (2)
- M test/instance-checks-5.err.expect https://github.com/evincarofautumn/kitten/pull/134/files#diff-47 (4)
- M test/instance-checks-5.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-48 (2)
- M test/instance-checks-6.err.expect https://github.com/evincarofautumn/kitten/pull/134/files#diff-49 (6)
- M test/instance-checks-6.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-50 (2)
- M test/instance-checks-7.err.expect https://github.com/evincarofautumn/kitten/pull/134/files#diff-51 (6)
- M test/instance-checks-7.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-52 (2)
- M test/instance-checks-8.err.expect https://github.com/evincarofautumn/kitten/pull/134/files#diff-53 (12)
- M test/instance-checks-8.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-54 (2)
- M test/instance-checks-9.err.expect https://github.com/evincarofautumn/kitten/pull/134/files#diff-55 (10)
- M test/instance-checks-9.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-56 (2)
- M test/int.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-57 (10)
- M test/levenshtein.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-58 (2)
- M test/literal-error.err.expect https://github.com/evincarofautumn/kitten/pull/134/files#diff-59 (4)
- M test/literal-error.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-60 (2)
- M test/literals.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-61 (2)
- M test/many-resolve-errors.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-62 (4)
- M test/non-function-type-signature.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-63 (2)
- M test/occurs-check.err.expect https://github.com/evincarofautumn/kitten/pull/134/files#diff-64 (10)
- M test/occurs-check.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-65 (6)
- M test/option.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-66 (6)
- M test/precedence-1.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-67 (2)
- M test/precedence-2.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-68 (2)
- M test/range.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-69 (2)
- M test/splitAt.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-70 (2)
- M test/stream.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-71 (2)
- M test/type-error-1.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-72 (2)
- M test/type-error-2.err.expect https://github.com/evincarofautumn/kitten/pull/134/files#diff-73 (10)
- M test/type-error-2.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-74 (2)
- M test/type-error-3.err.expect https://github.com/evincarofautumn/kitten/pull/134/files#diff-75 (10)
- M test/type-error-3.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-76 (2)
- M test/type-error-4.err.expect https://github.com/evincarofautumn/kitten/pull/134/files#diff-77 (6)
- M test/type-error-4.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-78 (2)
- M test/type-error-5.err.expect https://github.com/evincarofautumn/kitten/pull/134/files#diff-79 (14)
- M test/type-error-5.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-80 (4)
- M test/type-error-6.err.expect https://github.com/evincarofautumn/kitten/pull/134/files#diff-81 (14)
- M test/type-error-6.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-82 (4)
- M test/udt-polymorphic.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-83 (2)
- M test/udts.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-84 (2)
- M test/unicode-syntax.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-85 (10)
- M test/vector.ktn https://github.com/evincarofautumn/kitten/pull/134/files#diff-86 (6)
Patch Links:
- https://github.com/evincarofautumn/kitten/pull/134.patch
- https://github.com/evincarofautumn/kitten/pull/134.diff
— Reply to this email directly or view it on GitHub https://github.com/evincarofautumn/kitten/pull/134.
The counter argument is for Huffman coding - more frequently used things should be shorter, and less common things longer. This is the direction that Rust has been moving in. def
is used so much that it seems sensible (depending on your point of view) to have it short.
For a shorter keyword, I would accept something like let
:
let dup @a (a -> a a):
-> x; x x
let swap @a b (a b -> b a):
-> x y; y x
A mnemonic operator like Joy’s ==
(Unicode ≡
, “identical to”) would be okay. It would let the name always be at the beginning of a line, which is a style some people like in C. Presumably type term
would become valid syntax for denoting that term
must be an instance of type
, which is something we need anyhow.
dup == @a (a -> a a):
-> x; x x
swap == @a b (a b -> b a):
-> x y; y x
Any reason you can't drop the token entirely?
+ (Int -> Int): ...
By the way, feel free to ignore me – I'm not very invested in Kitten right now, so I'm just offering an alternative perspective.
Any reason you can't drop the token entirely?
No, but I would like some kind of explicit token to avoid ambiguity, and to be able to make it non-special in the future—e.g., desugaring define name body
to name body define__
.
I'm just offering an alternative perspective.
I appreciate all the input I can get. :)
This is part of a general effort to make Kitten’s syntax more ergonomic and consistent. Anyone want to voice objections? It’s longer, but I also don’t see a reason to have gratuitously abbreviated keywords like Rust, and the only language that Sam Developer has seen with
def
is Python, which could be a false friend.