Conversation
Notices
-
Hallå Kitteh (clacke@social.heldscal.la)'s status on Tuesday, 09-Jan-2018 15:37:49 UTC Hallå Kitteh @wolf480pl @cjd @rx14 Interesting! -
Caleb James DeLisle (cjd@mastodon.social)'s status on Monday, 08-Jan-2018 12:03:21 UTC Caleb James DeLisle @Wolf480pl
Static typing is fundimentally a form of static assertion, which I totally support, but I think the programmer should decide what classes if bugs they wish to assert against.There is another argument for static typing, that we have greater power over the asm that our code will generate. I have mixed feelings about this, on the one hand "never take away power from the programmer" on the other hand letting a jit decide after some profiling is probably better.
Hallå Kitteh repeated this. -
Hallå Kitteh (clacke@social.heldscal.la)'s status on Tuesday, 09-Jan-2018 11:03:04 UTC Hallå Kitteh @wolf480pl @cjd @rx14 Not every time. Sometimes it really is just a matter of finding the right deep invocation of combinations of qualifiers that allow you to do what you wanted, and which was the right thing to do all along.
Expressive type systems seem better at this, my experience is mostly with C++. Putting that const in exactly the right place and finding out what shortcut exists to expressing a type with eight pointy brackets in it. -
Hallå Kitteh (clacke@social.heldscal.la)'s status on Tuesday, 09-Jan-2018 11:03:58 UTC Hallå Kitteh @wolf480pl @cjd @rx14 You mean lexical scope? -
Hallå Kitteh (clacke@social.heldscal.la)'s status on Tuesday, 09-Jan-2018 11:36:13 UTC Hallå Kitteh @rx14 @cjd @wolf480pl It is my impression that there is a scale from:
- untyped langs (asm, forth, picolisp)
- to dynamically (strongly) typed langs (JS, Python, Ruby, Scheme)
- to statically (weakly) typed langs with typing so simplistic that you need holes in them everywhere to get anything done (C)
- to statically (weakly) typed langs with simplistic typing that has grown warts to hypothetically be able to avoid holes, but still has the holes (C++)
- to statically (strongly) typed langs that don't have any holes, can reason about their functions, can do type inference, and types can even help define code and generate executable code (Haskell, ML)
- to langs with dependent types (Idris)
And basically you want to be in one of the strongly typed ones, or maybe the untyped ones, but most people are trapped with the weakly statically typed languages and therefore hate static typing. -
Hallå Kitteh (clacke@social.heldscal.la)'s status on Tuesday, 09-Jan-2018 11:38:26 UTC Hallå Kitteh @wolf480pl @cjd @rx14 The thing with lexical scope is, you can trivially do it at compile-time, so it doesn't make any sense to delay it. -
Hallå Kitteh (clacke@social.heldscal.la)'s status on Tuesday, 09-Jan-2018 12:06:23 UTC Hallå Kitteh @wolf480pl @cjd @rx14 It does. LOAD_DEREF picks the variable from the closure, a tuple known at compile-time, without looking up the name. If you try to make it reference a closure variable that doesn't exists at compile-time, it fails.
Or do you mean something special with "check"?
>>> def asdf():
... def inner():
... nonlocal qwer
... return qwer
... return inner
...
File "<stdin>", line 3
SyntaxError: no binding for nonlocal 'qwer' found
>>> def asdf():
... qwer = 0
... def inner():
... nonlocal qwer
... return qwer
... return inner
...
>>> dis.dis(asdf())
5 0 LOAD_DEREF 0 (qwer)
3 RETURN_VALUE
But the nonlocal is redundant if we don't want to rebind the value:
>>> def asdf():
... qwer = 0
... def inner():
... return qwer
... return inner
>>> dis.dis(asdf())
4 0 LOAD_DEREF 0 (qwer)
3 RETURN_VALUE
The compiler sees that qwer is a lexically scoped value and does LOAD_DEREF instead of a LOAD_GLOBAL.
>>> def asdf():
... return qwer
...
>>> dis.dis(asdf)
2 0 LOAD_GLOBAL 0 (qwer)
3 RETURN_VALUE
The compiler sees that there is no lexical 'qwer' and instead creates bytecode for a global lookup. -
Hallå Kitteh (clacke@social.heldscal.la)'s status on Tuesday, 09-Jan-2018 12:07:47 UTC Hallå Kitteh @cjd @wolf480pl @rx14
Ah yes, thanks GS for stripping my indents.
def inner():
..return qwer
return inner -
Hallå Kitteh (clacke@social.heldscal.la)'s status on Tuesday, 09-Jan-2018 15:20:56 UTC Hallå Kitteh @rx14 @cjd @wolf480pl
yourfile.lang:42:7: WARNING: This doesn't look quite right but maybe it'll sort itself out by runtime, who knows -
Hallå Kitteh (clacke@social.heldscal.la)'s status on Tuesday, 09-Jan-2018 15:36:07 UTC Hallå Kitteh @wolf480pl @cjd @rx14 I don't count type coercion as weak typing. The type system knows and enforces exactly what type it is, it just adds conversions where it deems necessary.
Type coercion can be dangerous to code quality and make debugging difficult, but not like weak typing.
Weak typing is where you reinterpret an object, so that you have a float and you can just go "I'm gonna interpret these bytes as an int now". -
Hallå Kitteh (clacke@social.heldscal.la)'s status on Tuesday, 09-Jan-2018 15:40:10 UTC Hallå Kitteh @cjd @wolf480pl @rx14 Masto FE on Pleroma BE does too.
-