[erlang-questions] Frames proposal

Richard O'Keefe ok@REDACTED
Wed May 2 03:11:11 CEST 2012


It would be *so* nice to discuss semantics...

> Only true for a range of QWERTY keyboards. There's a lot more layouts in the world.

Indeed.  It is impossible to optimise for all of them.

> Incidentaly on my keyboard writing <{}> is insanely difficult (takes a minimum of 2 seconds when trying to go fast), while #{} is not perfect but a lot easier (maybe half a second, hard to measure at this point). This is because the former requires me to press the sequence "<, ALT GR {, ALT GR }, SHIFT >", while the latter only requires "ALT GR #, ALT GR {, ALT GR }". The keys for # and { are also right next to the other, which isn't true for < and {.

You don't say which keyboard.  The frames proposal document notes a similar
issue for Swedish keyboards, and suggests allowing *both* <{...}> *and* <(...)>
as a way of coping with the problem.

However, since the problem with <{...}> appears to be due to the use of
the curly braces, surely this must make tuples and records already 'insanely
difficult'.

As for the difficulty of typing ~, code is READ more often than it is WRITTEN,
so the readability advantage much outweighs the typing disadvantage.

Modern text editors have abbreviation features which mean that you *should* be
able to set your text editor up so that 
	(,	expands to <{}> with the cursor in the middle
	=,	expands to  ~   with the cursor after it
so that typing "<{a ~ 1, b ~ 2}>" requires the keystrokes
	"(,a=,1, b=,2<fwd><fwd>"

It took me five minutes to write this code for my home-brew text editor:

void comma(void) {
    if (argvalue != implicit) {     
        putin();      
    } else
    switch (fetch(here)) {
	case ')':		   /* For Erlang expressions */
	case ']':		   /* For Erlang lists */
            here++;
	    break;
	case '}':	    	   /* For Erlang tuples and frames */
	case '>':		   /* For Erlang binaries */
	    here += fetch(here+1) == '>' ? 2 : 1;
	    break;
	default:
	    switch (fprev(here)) {
	        case '(':                  /* For Erlang frames */
	            delete(NORM, here-1);  
	            strinsert(1, 4, "<{}>");
	            here -= 2;
	            break;
		case '[':		   /* For Erlang tuples */
	            delete(NORM, here-1);  
	            strinsert(1, 2, "{}");
	            here--;
	            break;
		case ':':		   /* For Erlang records */
		    delete(NORM, here-1);
		    insert(1, '#');
		    break;
	        case '=':		   /* For Erlang frames */
	            delete(NORM, here-1);
	            strinsert(1, 3, " ~ ");
	            break; 
	        case ' ':   
	            here--;
	            insert(-1, ',');
	            here++;
	            break;
	        default:
	            putin();
	    }
    }
}    

After which it's just "(,a=,1, b=,2," which can't be _that_ hard to type.




More information about the erlang-questions mailing list