Generic symbol metaproposal

294 views
Skip to first unread message

Michael Jones

unread,
Jul 22, 2020, 10:19:03 PM7/22/20
to golang-nuts
One interesting fact of go is that semicolons are required at the end of statements. A fact forgotten perhaps because of the automatic ‘we’ll insert one for you’ process. This duality, required but auto-supplied in nearly every case is a delightful outcome. 

Another delight is the uppercase signal for external. 

Maybe the “how to signal it” aspect of type instantiation could look to these approaches as well—make the automatic understanding so magical that the complete specification is unnecessary in most all cases, or the signaling so intrinsic to the variables that no identification Symbol or BracketedPair is necessary. 

Do I have a perfect example? No. Imperfect, sure. 

Choice a: leading upper case means an exported symbol, all upper case means generic type. (Not Go 1 promise consistent) no special syntax/keyword needed!

Choice b: struct name a=int, b=MyType {...}
No parse issue about ‘struct name’ followed by an identifier, right?

Choice c: leading and trailing underscore on generic placeholder identifiers. Func MySqrt(x _t_)

These Examples are not deep thoughts. But the notion of no keyword or funky symbol In the 99.99% of cases is a deep thought. 

Michael
--
Michael T. Jones
michae...@gmail.com

fge...@gmail.com

unread,
Jul 24, 2020, 5:22:16 PM7/24/20
to Michael Jones, golang-nuts
On 7/23/20, Michael Jones <michae...@gmail.com> wrote:
...
> Another delight is the uppercase signal for external.
>
> Maybe the “how to signal it” aspect of type instantiation could look to
> these approaches as well—make the automatic understanding so magical that
> the complete specification is unnecessary in most all cases, or the
> signaling so intrinsic to the variables that no identification Symbol or
> BracketedPair is necessary.

Maybe braille?
⠓⠑⠇⠇⠕⠺⠕⠗⠇⠙
https://www.royalblind.org/sites/www.royalblind.org/files/alphavet.PNG

⠊⠞ ⠊⠎ ⠑⠁⠎⠽

Ian Lance Taylor

unread,
Jul 24, 2020, 5:51:17 PM7/24/20
to fge...@gmail.com, Michael Jones, golang-nuts
I've always felt that color is underused in modern programming languages.

func Max(T)(s []T) T


Ian

fge...@gmail.com

unread,
Jul 24, 2020, 6:12:16 PM7/24/20
to Ian Lance Taylor, Michael Jones, golang-nuts
Who came up with the idea of "begin with Lu for exported symbols"? Maybe there are other better ideas where that came from.

David Riley

unread,
Jul 24, 2020, 6:16:40 PM7/24/20
to Ian Lance Taylor, fge...@gmail.com, Michael Jones, golang-nuts
Perhaps there could be some cross-pollination with ColorForth, wherein color actually is semantically meaningful.

https://colorforth.github.io


- Dave

Michael Jones

unread,
Jul 26, 2020, 8:07:29 PM7/26/20
to David Riley, Ian Lance Taylor, fge...@gmail.com, golang-nuts
I'm never sure how much detail to share. The colorForth idea is a perfect example of the thought about "another dimension" of specification. (Albeit difficult to implement in practice). The upper/lower case signal is a good one, and easy; it is limiting, but not terribly, and offers easy frictionless specification.

The earlier comment about ";" being everywhere and nowhere in Go is important. It leads to the question "what can we intuit?" That is a fine starting place. For example, if the generic specification requires "()" or "[]" or whatever around type-concretization lists, but the parser will add them for you, then you'll never see either except in "pedantic" machine generated code or the rareish case of a generic type list that needs another generic type list as an element (the inner ones need delimiters).

I vote for this whatever symbol is chosen.

bugpowder

unread,
Jul 27, 2020, 5:39:57 PM7/27/20
to golang-nuts
IMHO uppercase, single letter for denoting generic types would be a nice syntax / convention.

Sure, that would limit to 26 generic types per function ("enough for everybody"?), and probably break some bizarro existing code (using uppercase single-letter characters for parameter names) -- thought said code probably deserves to be broken. 

Add constraints after each generic type (at the moment of first appearance), and serve to taste.

Another thing I like in old languages is the extra space afforded for metadata, variables, constraints (e.g. pre/postconditions) and definitions, e.g.

Eiffel:

		local
l_file: PLAIN_TEXT_FILE
sorted: STRING
empty_list: LINKED_LIST [STRING]

Ada:
   procedure Put (Position : Anagrams.Cursor) is
First : Boolean := True;
List  : Set renames Element (Position);

PL/I:
word_test: proc options (main);
declare words (50000) character (20) varying,
frequency (50000) fixed binary;
declare word character (20) varying;
declare (i, k, wp, most) fixed binary (31);

In general, not being constrained to have the list of arguments, modifiers, and metadata about the function inside a single pair of parenthesis.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CALoEmQz%3D5WA0K8OV5q_ONpxESzP7wEtkBZtF32AMT08bvFR0DQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages