strong-typing

ios confused about strong/weak references

半世苍凉 提交于 2019-11-29 15:47:30
问题 I've looked through the questions on strong/weak references, and understand the reason for using weak (the parent to child relationship). However, I'm confused about specific scenarios where a parent to child relationship is created. For example, is adding subviews to a UIView object..an example of creating a parent/child relationship? What is? So far, I did everything in my project using strong, nowhere have I used weak, but I'm not sure if I'll run into memory management issues (or how to

Derby's handling of NULL values

半世苍凉 提交于 2019-11-29 11:32:58
I am new to Derby and I noticed that I face similar problems as when using the DB2 RDBMS as far as null values are concerned. The Derby documentation states, that a null value must have a type associated with it (something that DB2 finally got rid of in version 9.7): http://db.apache.org/derby/docs/10.7/ref/crefsqlj21305.html Now, I am trying to find a general solution to this problem here as this will be a part of my database abstraction library jOOQ . The below example just documents the problem. Think of any other (more complex) example. The following doesn't work: insert into T_AUTHOR ( ID

What to do if a typings (or tsd) is not available?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 09:10:00
I was looking over the TypeScript handbook and I can't seem to find the answer. If I am using a library that no typings exist, what are my options? One is to create the typings file, but this I don't really want to do. What are my other options, I seem to remember some kind of 'declare' keyword ? Or maybe something in the tsconfig ? I assume there is a way of declaring this variable (type) globally so every time I use it, it would just work. And I presume there is a way of just declaring it only available in one file. Of course the best way would be to include a typings file but this won't

Emulating delegates with free generic type parameters in C#

廉价感情. 提交于 2019-11-29 06:53:16
This is a hard question about language design, patterns and semantics. Please, don't down-vote just because you don't see the practical value. First, let's think about functions and their parameters. Then we'll look at the analogies between functions with their parameters/arguments and generic classes/functions with their type-parameters/type-arguments. Functions are blocks of code with some unspecified values called " parameters ". You supply the arguments and receive the result. Generic classes are classes with some unspecified " type-parameters ". You supply the type-arguments and then you

Are scalar and strict types in PHP7 a performance enhancing feature?

ぐ巨炮叔叔 提交于 2019-11-29 05:25:30
Since PHP7 we can now use scalar typehint and ask for strict types on a per-file basis . Are there any performance benefits from using these features? If yes, how? Around the interwebs I've only found conceptual benefits, such as: more precise errors avoiding issues with unwanted type coercion more semantic code, avoiding misunderstandings when using other's code better IDE evaluation of code Today, the use of scalar and strict types in PHP7 does not enhance performance. PHP7 does not have a JIT compiler. If at some time in the future PHP does get a JIT compiler, it is not too difficult to

Initializing strongly typed objects in LINQ to Entities

若如初见. 提交于 2019-11-29 01:51:58
I have a plain old CLR object which is essentially a wrapper for two entity framework objects, I'm doing this so I can pass this wrapper object to a strongly typed view in the MVC framework. My foo wrapper class is very simple: public class FooWrapper { public FooWrapper(Foo f, Bar b) { this.FooObject = f; this.BarObject = b; } public Foo FooObject { get; private set; } public Bar BarObject { get; private set; } } What I have so far for my ListFoosWithBars function is as follows: public IEnumerable<FooWrapper> ListFoosWithBars(int userID) { IEnumerable<Bar> tempBar = ListBarsByUserID(userID);

Strong Typing a property name in .NET

荒凉一梦 提交于 2019-11-28 21:38:48
Say I have a class with one property Public Class MyClass Public Property MyItem() as Object .... End Property End Class I have to pass the name of the property to a function call. (Please don't ask why it should be done this way, its a third party framework). For example SomeFunc("MyItem") But what I would like to do is, change the string into a strongly typed parameter. Meaning, if the property name is renamed or changed, it should be reflected here too. So something of this type : Dim objectForStrongTyping as New MyClass() SomeFunc(objectForStrongTyping.MyItem().Name()) I am sure this won't

template argument deduction with strongly-typed enumerations

混江龙づ霸主 提交于 2019-11-28 21:09:32
问题 If I have a normal (weak) enumeration, I can use its enumerated values as non-type template parameters, like so: enum { Cat, Dog, Horse }; template <int Val, typename T> bool magic(T &t) { return magical_traits<Val>::invoke(t); } and call it as: magic<Cat>(t) as far as I can see, if I have a strongly-typed enumeration and don't want to hard-code the enumeration type, I end up with: enum class Animal { Cat, Dog, Horse }; template <typename EnumClass, EnumClass EnumVal, typename T> bool magic(T

Is Python a weakly typed language as variables can switch types?

回眸只為那壹抹淺笑 提交于 2019-11-28 20:51:30
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 NOT to let me change type just like that, but the Python equivalent of the above code works just like in PHP yikes! >>> var = "Hello" >>> type(var) <type 'str'> >>> var = 5 >>> type(var) <type 'int'> Is my understanding of weak/strong typing flawed? Your example demonstrates dynamic typing, not weak typing. Dynamic typing generally means that the type of data an object can store is mutable; any target

Compile Time Reflection in C#

萝らか妹 提交于 2019-11-28 18:20:35
I frequently write C# code that has to use magic strings to express property names. Everyone knows the problems with magic strings. They are very difficult to refactor, they have no compile time checking, and often they lead to hard-to-diagnose issues. Yet C#/.NET uses them all over the place to represent property/class/method names. This issue has persisted for years and years, and the only viable solution currently is to use an expression tree which is then parsed at run-time for the property name. This gets you satisfactory compile-time checking, but it complicates the code (requiring