definition

F# - What is array<'T>?

懵懂的女人 提交于 2019-12-04 06:50:54
In this previous question I learnt that in F# an array<'T> is not the same as System.Array . VS tells me that array<'T> inherits System.Array and has the full name Microsoft.FSharp.Core.array<_> and some additional Interfaces. However MSDN says that array<'T> is a type abbreviation of System.Array . And that it has the notation arr.[i] to get and set items. So for my lesson, is array<'T> a type abbreviation that includes type extensions and additional Interfaces? Where is the best place to look this up ? The type array<'T> is an abbreviation, but not for the base type System.Array but for

When exactly does a method have side effects?

梦想与她 提交于 2019-12-04 05:01:00
As I always understood it, any change to the programs state (or anything to do with IO) is a side effect. It does not matter, whether the change occurs in a global variable or in a private field of the object the method is called on. It follows that all methods which do not return anything either do nothing at all or have a side effect. My confusion comes from one of our university's instructors (who is still a student and thus not omniscient yet;) ) telling me setters don't have side effects. runako Your instructor is mistaken. With apologies to the SO editors for not pasting the entire

Why does one have to repeat the const specifier at definition time, if declaration as const is done somewhere else?

 ̄綄美尐妖づ 提交于 2019-12-04 05:00:40
问题 After solving this simple issue, I had to ask : -> In the H file in a class ex a const static member is defined, e.g. : class ex { const static int my_ex; }; -> In the CPP file the value is specified ex::my_ex = 32; And then one gets the error "conflicting declarations" (as well as "does not name a type"). I understand that the definition in the CPP file is also a declaration which does create a conflict seen from the linker BUT why only about the const specifier (and type) and not the static

What is the datatype bytea and when would I use it?

大憨熊 提交于 2019-12-04 02:46:49
问题 In Postgres there is a datatype called bytea The Postgres docs are here for it: http://www.postgresql.org/docs/9.0/static/datatype-binary.html I cannot understand when I would ever use this - nor can I really understand the purpose of this datatype. I have come across this term bytea several times and starting to wonder to myself "It seems like they expect me to understand this... Maybe I should find out what it is." If anybody can give a simple definition for it and some given circumstance

Practical difference between def f(x: Int) = x+1 and val f = (x: Int) => x+1 in Scala

≯℡__Kan透↙ 提交于 2019-12-04 02:18:27
I'm new to Scala and I'm having a problem understanding this. Why are there two syntaxes for the same concept, and none of them more efficient or shorter at that (merely from a typing standpoint, maybe they differ in behavior - which is what I'm asking). In Go the analogues have a practical difference - you can't forward-reference the lambda assigned to a variable, but you can reference a named function from anywhere. Scala blends these two if I understand it correctly: you can forward-reference any variable (please correct me if I'm wrong). Please note that this question is not a duplicate of

Why is a non-static data member reference not a variable?

我的未来我决定 提交于 2019-12-04 00:49:56
问题 The definition of a variable in C++11 is as follows (§3/6): A variable is introduced by the declaration of a reference other than a non-static data member or of an object. The variable’s name denotes the reference or object. So a non-static data member reference is not a variable. Why is this distinction necessary? What's the rationale here? 回答1: Here's one way I can declare a variable in C++: int scientist = 7; After this declaration (and definition, in this case), I can use scientist to

separate real and imaginary part of a complex number in python

守給你的承諾、 提交于 2019-12-03 22:46:23
I have need to extract the real and imaginary elements of a complex number in python. I know how to make a list into a complex number... but not the other way around. I have this: Y = (-5.79829066331+4.55640490659j) I need: Z = (-5.79829066331, 4.55640490659) and I will also need each part if there is a way to go directly without going by way of Z: A = -5.79829066331 B = 4.55640490659 https://docs.python.org/2/library/functions.html#complex Thanks! Y = (-5.79829066331+4.55640490659j) Z = (Y.real, Y.imag) A = Y.real B = Y.imag Z = (Y.real, Y.imag) A = Y.real B = Y.imag import numpy as np #Can

Why must unused virtual functions be defined?

喜夏-厌秋 提交于 2019-12-03 20:59:32
问题 I find it quite odd that unused virtual functions must still be defined unlike unused ordinary functions. I understand somewhat about the implicit vtables and vpointers which are created when a class object is created - this somewhat answers the question (that the function must be defined so that the pointers to the virtual function can be defined) but this pushes my query back further still. Why would a vtable entry need to be created for a function if there's absolutely no chance that

Explanation of BASE terminology

可紊 提交于 2019-12-03 18:17:40
问题 The BASE acronym is used to describe the properties of certain databases, usually NoSQL databases. It's often referred to as the opposite of ACID. There are only few articles that touch upon the details of BASE, whereas ACID has plenty of articles that elaborate on each of the atomicity, consistency, isolation and durability properties. Wikipedia only devotes a few lines to the term. This leaves me with some questions about the definition : B asically A vailable, S oft state, E ventual

Unit Testing - definitions

左心房为你撑大大i 提交于 2019-12-03 16:40:00
Like anything else understanding the words makes it much easier to learn the language. Can anyone chime in with all the words used in unit testing with their definitions (ex. Mock, Fixture, etc. ) Jonathan Parker This looks like a great page: http://xunitpatterns.com/Glossary.html It includes: SUT synchronous test task TDD test automater test case test code test condition test context test database test debt test driver test driving test error test failure test fixture test fixture test fixture test maintainer test package test reader test result test run test smell test stripper test success