semantics

When is it better to use a Tuple versus a KeyValuePair?

六眼飞鱼酱① 提交于 2019-12-02 19:53:32
I've generally used the KeyValuePair<TKey,TValue> type whenever I have data that is pair-related in the sense that one is a key to the other. If the data is unrelated then the Tuple<T1,T2> type makes more sense and I'd go with that. Now I just read this article about why to generally avoid KeyValuePair<TKey,TValue> and prefer Tuple<T1,T2> . The primary argument being the performance benefit of Tuple<T1,T2> . Outside performance, is there any reason a KVP would be a better choice than a Tuple<T1,T2> ? vcsjones Well, the type could be considered poorly named, for one. A KeyValuePair as named

Semantics of char a[]

旧巷老猫 提交于 2019-12-02 19:27:44
I recently embarrassed myself while explaining to a colleague why char a[100]; scanf("%s", &a); // notice a & in front of 'a' is very bad and that the slightly better way to do it is: char a[100]; scanf("%s", a); // notice no & in front of 'a' Ok. For everybody getting ready to tell me why scanf should not be used anyway for security reasons: ease up. This question is actually about the meaning of "&a" vs "a". The thing is, after I explained why it shouldn't work, we tried it (with gcc) and it works =)). I ran a quick printf("%p %p", a, &a); and it prints the same address twice. Can anybody

Building or Finding a “relevant terms” suggestion feature

ⅰ亾dé卋堺 提交于 2019-12-02 18:36:09
Given a few words of input, I want to have a utility that will return a diverse set of relevant terms, phrases, or concepts. A caveat is that it would need to have a large graph of terms to begin with, or else the feature would not be very useful. For example, submitting "baseball" would return ["shortstop", "Babe Ruth", "foul ball", "steroids", ... ] Google Sets is the best example I can find of this kind of feature, but I can't use it since they have no public API (and I wont go against their TOS). Also, single-word input doesn't garner a very diverse set of results. I'm looking for a

Is OO design's strength in semantics or encapsulation?

喜欢而已 提交于 2019-12-02 16:21:45
Object-oriented design (OOD) combines data and its methods. This, as far as I can see, achieves two great things: it provides encapsulation (so I don't care what data there is, only how I get values I want) and semantics (it relates the data together with names, and its methods consistently use the data as originally intended). So where does OOD's strength lie? In constrast, functional programming attributes the richness to the verbs rather than the nouns, and so both encapsulation and semantics are provided by the methods rather than the data structures. I work with a system that is on the

Frameworks vs. SDKs

感情迁移 提交于 2019-12-02 16:16:00
What is the difference between a framework and an SDK? Take, for example, the MS platform SDK and the .NET framework. Both have API's, both hide their inner workings, and both provide functionality that may not be quickly/easily accessible otherwise (in other words, they serve a real-world purpose). So what's the difference? Is it primarily a marketing game of semantics, or are there actual differences in how developers are expected to interact with the software (and conversely, how the developers can expect the software to behave)? Is one expected to be higher- or lower-level than the other,

Does a <button> TYPE have to be defined?

一曲冷凌霜 提交于 2019-12-02 10:56:18
When using the button tag, does the type attribute have to be defined, or is it semantic to just have? <button>Click Me</button> No, you don't have to specify it, it defaults to the value submit . See the HTML 4.x specification : type (button|submit|reset) submit -- for use as form button -- ^^^^^^ default value Compare with the action attribute for forms where it says #REQUIRED instead of giving a default value. action %URI; #REQUIRED -- server-side form handler -- As @Quentin’s answer explains, the type attribute is not required and it defaults to submit . There is no change to this in HTML5

What are the semantics of mutably borrowing a literal in Rust? [duplicate]

雨燕双飞 提交于 2019-12-02 10:34:58
问题 This question already has answers here : Why is it legal to borrow a temporary? (3 answers) Why isn't this rvalue promoted to an lvalue as specified in the reference? (1 answer) Closed last year . I found that this is able to compile: let x = &mut 10; *x = 20; This is very confusing. What are the semantics of mutably borrowing an literal? I come from C++, where the compiler will definitely not allow me to refer to a rvalue like this: int *x = &10; int &y = 10; 回答1: Like C++, Rust has the

ElseIf vs Else If

China☆狼群 提交于 2019-12-02 07:49:25
问题 For years now I've been using Else If to code in VBScript... If a = b Then ... Else If a = c Then ... End If Which seems to work as required. I've also seen many sites on the web that use Else If , excepting MSDN that uses ElseIf . Is there a difference between ElseIf versus Else If ? Snippet Here's one I coded earlier that's working just fine through Classic ASP: If IsDate(wD) Then wS = wD Else If wD&"" <> FormatDisplayDate(wS) Then wS = WeekStart(Date()) wD = FormatDisplayDate(wS) End If

Modelica Discrete Semantics

让人想犯罪 __ 提交于 2019-12-02 07:23:08
I am trying to understand the Modelica semantics for a discrete signal. Given a step signal that instantaneously transitions from 0.0 to 1.0 with infinite slope at t = 0.5. Then let's say you also have a when statement as in the following code: model test_discrete Modelica.Blocks.Interfaces.RealOutput q(start = -1.0); Modelica.Blocks.Sources.Step step( height=1, offset=0, startTime=0.5) algorithm when time >= 0.5 and time <= 0.5 then q := step.y; end when; equation end test_discrete; My question is whether q will be 0.0 or 1.0? Lets assume q is initialized to -1. When I implement the code, it

What are the semantics of mutably borrowing a literal in Rust? [duplicate]

喜你入骨 提交于 2019-12-02 06:34:21
This question already has an answer here: Why is it legal to borrow a temporary? 3 answers Why isn't this rvalue promoted to an lvalue as specified in the reference? 1 answer I found that this is able to compile: let x = &mut 10; *x = 20; This is very confusing. What are the semantics of mutably borrowing an literal? I come from C++, where the compiler will definitely not allow me to refer to a rvalue like this: int *x = &10; int &y = 10; Like C++, Rust has the concept of rvalues and lvalue. The reference calls them value expressions (rvalue) and place expressions (lvalue). Additionally, there