如何在vim中翻转窗口?(How to flip windows in vim? [duplicate])
可能重复:
在Vim中快速从垂直分割切换到水平分割如果我有2个水平拆分窗口,如何旋转它们以获得2个垂直分割窗口?
和如何切换缓冲区?
Possible Duplicate:
To switch from vertical split to horizontal split fast in VimIf I have 2 horizontally split windows, how to rotate them to get 2 vertically split windows?
And how to switch buffers?
原文:https://stackoverflow.com/questions/6071266
最满意答案
那么,它们在“构造函数”这个词的任何正常用法中都不是真正的“构造函数”。
它们是可以转换为委托类型或表达式树类型的表达式 - 后者在处理进程外的LINQ时非常重要。
如果你真的问是否期望使用两个“等价”lambda表达式可以创建不平等的委托实例:是的,它是。 IIRC,C#语言规范甚至还声明这种情况。
但是,多次使用相同的lambda表达式不会总是创建不同的实例:
using System; class Test { static void Main(string[] args) { Action[] actions = new Action[2]; for (int i = 0; i < 2; i++) { actions[i] = () => Console.WriteLine("Hello"); } Console.WriteLine(actions[0] == actions[1]); } }
在我的盒子上,它实际上打印了
True
-actions[0]
和actions[1]
具有完全相同的值 - 它们指向相同的实例。 事实上,我们可以走得更远:using System; class Test { static void Main(string[] args) { object x = CreateAction(); object y = CreateAction(); Console.WriteLine(x == y); } static Action CreateAction() { return () => Console.WriteLine("Hello"); } }
再次,这打印
True
。 不能保证,但在这里编译器实际上已经创建了一个静态字段来缓存第一次需要的委托 - 因为它没有捕获任何变量等。基本上这是一个你不应该依赖的编译器实现细节。
Well, they're not really "constructors" in any of the normal uses of the word "constructor".
They're expressions which can be converted to delegate types or expression tree types - the latter being essential when it comes to out-of-process LINQ.
If you're really asking whether it's expected that using two "equivalent" lambda expressions can create unequal delegate instances: yes, it is. IIRC, the C# language specification even calls out that that's the case.
However, using the same lambda expression more than once won't always create different instances:
using System; class Test { static void Main(string[] args) { Action[] actions = new Action[2]; for (int i = 0; i < 2; i++) { actions[i] = () => Console.WriteLine("Hello"); } Console.WriteLine(actions[0] == actions[1]); } }
On my box, that actually prints
True
-actions[0]
andactions[1]
have the exact same value - they refer to the same instance. Indeed, we can go further:using System; class Test { static void Main(string[] args) { object x = CreateAction(); object y = CreateAction(); Console.WriteLine(x == y); } static Action CreateAction() { return () => Console.WriteLine("Hello"); } }
Again, this prints
True
. It's not guaranteed to, but here the compiler has actually created a static field to cache the delegate the first time it's required - because it doesn't capture any variables etc.Basically this is a compiler implementation detail which you should not rely on.
相关问答
更多-
那么,它们在“构造函数”这个词的任何正常用法中都不是真正的“构造函数”。 它们是可以转换为委托类型或表达式树类型的表达式 - 后者在处理进程外的LINQ时非常重要。 如果你真的问是否期望使用两个“等价”lambda表达式可以创建不平等的委托实例:是的,它是。 IIRC,C#语言规范甚至还声明这种情况。 但是,多次使用相同的lambda表达式不会总是创建不同的实例: using System; class Test { static void Main(string[] args) { ...
-
你在谈论lambda函数吗? 喜欢 lambda x: x**2 + 2*x - 5 那些事情其实是非常有用的。 Python支持一种称为函数式编程的编程风格,您可以将函数传递给其他函数来执行操作。 例: mult3 = filter(lambda x: x % 3 == 0, [1, 2, 3, 4, 5, 6, 7, 8, 9]) 将mult3设置为[3, 6, 9] mult3 [3, 6, 9] ,原始列表中的那些元素是3的倍数。这是较短的(可以争辩,更清晰) def filterfunc(x) ...
-
在TypeScript中,接口可以有呼叫签名。 在你的例子中,你可以这样声明: interface Greeter { (message: string): void; } function sayHi(greeter: Greeter) { greeter('Hello!'); } sayHi((msg) => console.log(msg)); // msg is inferred as string In TypeScript, interfaces can have call ...
-
如何将lambda代码映射到接口实现的确切决定留给实际的运行时环境。 原则上,实现相同原始接口的所有lambdas都可以像MethodHandleProxies一样共享一个运行时类。 对于特定的lambdas使用不同的类是由实际的LambdaMetafactory实现执行的优化 ,但不是旨在帮助调试或反射的功能。 因此,即使您在lambda接口实现的实际运行时类中找到更详细的信息,它将是当前使用的运行时环境的工件,可能在不同的实现或当前环境的其他版本中可用。 如果lambda是Serializable您可以 ...
-
兰巴达斯和类型推理(Lambdas and type inference)[2022-12-29]
原因很简单: 如何编译得出它应该是Func? 他简单不能! 假设你有自己的代理人: public delegate int F(int i); 编译器如何在Func 和F之间进行选择? 这些是完全不同的类型,有两个共同点:有两个委托并具有相同的签名(一个参数和返回类型,都是int类型)。 所以编译器不能选择; 你将不得不这样做: var funs = Enumerable.Range(0, 10).Select >(x => y ... -
我在这看到两个真正的区别: 第一个是如何存储回调:fast-delegate或std :: function。 后者基于boost :: function,快速代理专门设计为优于那些。 但是,std :: function符合标准,而快速代理则不符合标准。 另一个不同之处在于您设置代码的方式,我在这里看到了lambdas的明显优势。 您可以将实际代码准确地写在重要的位置,您不需要定义仅用于特定目的的单独函数。 如果你想要原始速度 - 快速代表可能会赢(但你应该基准测试,如果这是一个参数),但如果你想要可读性 ...
-
是的,那不是很漂亮......但你可以使用一个辅助方法,如下所示: public class StructInputValidator
: InputValidator where T : struct { public StructInputValidator(TryParse parser, T? initialValue) : base(ToNullableTryParse(parser), initialValue) { } priva ... -
委托 - 它不是方法签名。 It is a type which encapsulates a method 。 因此委托声明应该有一个类似于它想要封装的方法的签名。 When to use Delegate - whenever you want to pass a method to another function. 欲了解更多信息,请参阅本文 。 兰姆达斯 - 写作一个匿名函数的简短手段和更具表现力的方式。 但还有更多。 lambda表达式也可以转换为表达式树。 欲了解更多,请参阅。 匿名功能 - ...
-
我没有NUnit来验证,但可能是你需要显式地将Lambda强制转换为Delegate以强制适当的重载解析: Assert.That((Action)(()=>viewModel.SaveCommand_Exec(this, new ExecutedRoutedEventArgs())), Throws.Nothing); I don't have NUnit to verify but it could be that you need to explicitly cas ...
-
这是你想要的吗?: Func
a = p0 => p0 << 1; Func b = (p0, p1) => p0 + p1; Delegate da = a; Delegate db = b; var inner = da.Method.GetParameters().Length < db.Method.GetParameters().Length ? da : db; var outer = inner == da ? db : da; Func ...