strong-typing Questions

18

Solved

To quote Wikipedia: Two commonly used languages that support many kinds of implicit conversion are C and C++, and it is sometimes claimed that these are weakly typed languages. However, oth...
Janenejanenna asked 9/1, 2009 at 23:54

2

Solved

I am creating a data-file that looks like this: interface ISprite { textureName: string, frame: Frame, origin: Vec2, zIndex?: number } export let sprites: Record<string, ISprite> = { mo...
Kalinin asked 4/7, 2021 at 15:23

7

As a thought experiment on a hobby project, I've been thinking of a way to ensure that this sort of subtle bug/typo doesn’t happen: public void MyMethod(int useCaseId) { // Do something with the ...
Crosseye asked 10/8, 2010 at 11:46

20

Solved

I'd love to be able to do this: class myInt : public int { }; Why can't I? Why would I want to? Stronger typing. For example, I could define two classes intA and intB, which let me do intA + i...
Rosinarosinante asked 26/1, 2010 at 22:7

7

Solved

Suppose I have some enum E { A = "a", B = "b"}. I would like to force some interfaces or types(for the sake of readability I'll mention only interfaces) to have all the keys of E. However, I want ...
Russel asked 13/8, 2018 at 20:7

6

Solved

I've always considered C++ to be one of the most strongly typed languages out there. So I was quite shocked to see Table 3 of this paper state that C++ is weakly typed. Apparently, C and C++ are c...
Malevolent asked 5/11, 2014 at 9:23

3

I've seen the following new line in PHP 7, but nobody really explains what it means. I've googled it and all they talk about is will you be enabling it or not like a poll type of thing. declare(st...
Aplacental asked 10/2, 2018 at 17:35

11

Solved

What is the difference between Static/Dynamic and Strong/Weak typing?

5

Solved

The way I understand it, the following is allowed in PHP because it's a weakly-typed language. $var = 'Hello'; $var = 5; I just installed a Windows version of Python 2.6 and I was expecting it N...
Mordy asked 8/1, 2010 at 3:43

0

Suppose you have a function that takes a boolean argument: void do_something(bool use_some_option); This has issues because on the call site, you see something like do_something(false) which is no...
Grimsley asked 26/8, 2022 at 14:15

3

Solved

string name = null; name.ToLower(); In most languages such code would compile. Which languages would catch this and the like errors at compile time ? The only one I know uptil now is elm: http://e...
Infant asked 11/2, 2016 at 15:36

2

I have a String Union that looks like: type AlphabetLike = 'a' | 'b' | 'c' | 'zeta' | 'beta' | 'gamma' | 'mu'; I want to be able to construct the type type Alphabet = 'a' | 'b' | 'c'. I could do th...
Cowen asked 28/6, 2022 at 18:56

3

Solved

When chaining functionality in typescript with anonymous types for example like this: let array = [{ seed: 2 }, { seed: 3 }]; array .map(i => ({ seed: i.seed, square: i.seed * i.seed })) .f...
Rickierickman asked 12/4, 2016 at 11:32

13

Solved

I've come across links that say Python is a strongly typed language. However, I thought in strongly typed languages you couldn't do this: bob = 1 bob = "bob" I thought a strongly typed language...
Ignite asked 4/7, 2012 at 12:16

4

Solved

According to Dart's website Dart is a sound language. What's the meaning of "sound" in the above sentence? I couldn't find any similar concept in other major programming languages. Can ...
Kitchenware asked 19/3, 2018 at 10:33

3

Solved

With plain enums I was able to access Q_ENUMS properties and specific, the character represenation of enums, with following code: // in .h class EnumClass : public QObject { Q_OBJECT public: enu...
Tetherball asked 19/10, 2015 at 13:3

3

Solved

I'm exploring Julia so I'm a newbie. Now I'm exploring its strongly typed features. What I'm realizing is that I can't see the usage of abstract types for arrays. Let me explain with an example: L...
Lobell asked 1/3, 2016 at 8:26

11

Solved

Can I make a NSMutableArray instance where all the elements are of type SomeClass?

2

Solved

>>> from typing import overload >>> @overload ... def hello(s: int): ... return "Got an integer!" >>> def hello(s: str): ... return "Got a string" Why does the callin...
Faker asked 27/8, 2018 at 7:43

2

Solved

I am using vue composition api with typescript. How can I strongly type the component props using typescript typing system?
Canady asked 29/1, 2020 at 11:43

1

Solved

I have a system used for passing JSON messages back and forth over a socket connection. It uses Tagged Unions for the message types: export type ErrorMessage = { kind: 'error', errorMessage: Error...
Gimlet asked 24/9, 2017 at 17:15

2

TypeScript uses compile time (static) duck typing. I am a fan of extending primitive types to prevent incorrect substitution. For example, I like to give a credit card number variable a credit car...
Butterworth asked 26/3, 2014 at 23:2

2

Solved

There is a great Q/A here already for creating an untyped dictionary in Python. I'm struggling to figure out how to create a typed dictionary and then add things to it. An example of what I am tryi...
Coelacanth asked 19/4, 2019 at 1:6

3

Why the sizeof any pointer is 4 or 8 bytes, but it cannot fit any different variable? I get error while trying to assign a double pointer an int pointer value. int *int_ptr{nullptr}; float *float_...
Foucault asked 8/4, 2019 at 12:3

© 2022 - 2024 — McMap. All rights reserved.