language-design Questions

5

Solved

I have a struct that's defined like this: struct Vec3 { float x, y, z; }; When I attempted to use std::unique on a std::vector<Vec3>, I was met with this error: Description Resource ...

2

The std::ranges::view concept in C++23 requires a view to be movable, which includes move-assignability. I understand why we want a view to be move-constructible, but why is the assignment necessar...

2

Solved

I just noticed that int arr2[(777, 100)] is a legal array declarator, while int arr1[777, 100] is not. A more verbose example for compiling would be this #include <stdio.h> void f(int i) { ...

7

Solved

Is there a Python design decision (PEP) that precludes a sorted container from being added to Python? (OrderedDict is not a sorted container since it is ordered by insertion order.)
Knorr asked 10/5, 2011 at 16:24

6

Solved

Here's an excerpt from Sun's Java tutorials: A switch works with the byte, short, char, and int primitive data types. It also works with enumerated types (discussed in Classes and Inheritance) a...
Heidt asked 20/4, 2010 at 15:7

2

Solved

In Rust, asynchronous functions do not require allocating on the heap. Function async returns a compiler-generated structure on which you call a compiler generated poll method. The design of async ...

5

Solved

There are many people who think that the concept of the special value null (as it is used in lanuages like C, Java, C#, Perl, Javascript, SQL etc.) is a bad idea. There are several questions about ...
Merce asked 23/1, 2015 at 9:0

12

Solved

I have this code: award_dict = { "url": "http://facebook.com", "imageurl": "http://farm4.static.flickr.com/3431/3939267074_feb9eb19b1_o.png", "count&...
Parallelism asked 21/9, 2009 at 5:20

15

Solved

Are there any programming languages designed to define the solution to a given problem instead of defining instructions to solve it? So, one would define what the solution or end result should look...
Emblem asked 6/8, 2009 at 13:11

6

Given this code: trait Base { fn a(&self); fn b(&self); fn c(&self); fn d(&self); } trait Derived : Base { fn e(&self); fn f(&self); fn g(&self); } struct S; ...
Countertype asked 20/2, 2015 at 15:49

12

Solved

I'm designing a language, and trying to decide whether true should be 0x01 or 0xFF. Obviously, all non-zero values will be converted to true, but I'm trying to decide on the exact internal represen...
Codie asked 7/4, 2009 at 19:13

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

10

Solved

In several modern programming languages (including C++, Java, and C#), the language allows integer overflow to occur at runtime without raising any kind of error condition. For example, consider t...

6

Solved

What is the rationale for not having static constructor in C++? If it were allowed, we would be initializing all the static members in it, at one place in a very organized way, as: //illegal C++ ...

12

I have been dealing a lot with Lua in the past few months, and I really like most of the features but I'm still missing something among those: Why is there no continue? What workarounds are there...
Sled asked 19/8, 2010 at 18:24

3

Solved

The legacy std::for_each returns function as the standard only requires Function to meet Cpp17MoveConstructible according to [alg.foreach]: template<class InputIterator, class Function> con...
Ascension asked 28/9, 2023 at 11:59

1

C++20 added concepts, and the standard library includes quite a few of them. One concept in particular caught my eye: std::invocable which validates that a functor can be invoked with a set of argu...
Veronikaveronike asked 25/9, 2023 at 11:28

1

C++20 has made it possible to default comparison operators, including the three-way comparison like this. <=> can have a deduced return type, but other operators can't: struct S { friend aut...

5

Solved

I know the language specification forbids partial specialization of function template. I would like to know the rationale why it forbids it? Are they not useful? template<typename T, typename U&...

4

Solved

There are a lot of *_v and *_t suffixes, like std::is_same_v, std::invoke_result_t, result_of_t and milions of other such functions. Why do they exist at all? Is it beneficial in any context to exp...
Rood asked 11/9, 2023 at 17:32

1

Solved

[namespace.std] disallows taking the address of, or a reference to, most functions in the std namespace. This is a big pitfall, as it often seems to work to pass a standard-library function as an a...
Precedency asked 1/7, 2022 at 16:51

2

Solved

std::byte is an abstraction that is supposed to provide a type safe(r) access to regions of memory in C++, starting with the new standard 17. However, it's declared this way according to http://en....
Churr asked 12/6, 2017 at 20:27

3

Solved

We have equivalent assignment operators for all Logical operators, Shift operators, Additive operators and all Multiplicative operators. Why did the logical operators get left out? Is there a good...

3

Solved

HttpStatusCode is implemented as an enum, with each possible value assigned to its corresponding HTTP status code (e.g. (int)HttpStatusCode.Ok == 200). However, HttpMethod is implemented as a class...
Valval asked 27/9, 2016 at 6:29

7

An off-side language is the one where ...the scope of declarations (a block) in that language is expressed by their indentation. Examples of such languages are Python, Boo, Nemerle, YAML and ...
Glance asked 1/2, 2010 at 16:52

© 2022 - 2024 — McMap. All rights reserved.