REPL semantics

Luís Marques luis at luismarques.eu
Thu Jul 12 21:15:46 UTC 2018


On Thursday, 12 July 2018 at 20:33:04 UTC, jmh530 wrote:
> On Thursday, 12 July 2018 at 19:07:15 UTC, Luís Marques wrote:
> Most REPLs I've used are for languages with dynamic typing. 
> Perhaps take a look at a C REPL and see what it does?

Well, cling calls the original function:

[cling]$ #import <stdio.h>
[cling]$ void foo(long x) { printf("long\n"); }
[cling]$ void bar() { foo(42); }
[cling]$ void foo(int x) { printf("int\n"); }
[cling]$ bar()
long

...but to me that doesn't mean much. If it was the other way 
around (bar was updated to call foo(int)) I think I could safely 
conclude that it was an intended consequence. But the actual 
behavior can easily be explained by the fact that that's the most 
straightforward implementation (especially for a REPL that uses 
an existing C++ frontend, like clang). I was looking for a more 
fundamental answer: what would the user prefer to happen?


More information about the Digitalmars-d mailing list