ref

Why can't a function with byref be converted directly to delegate?

岁酱吖の 提交于 2019-12-19 07:23:47
问题 Under normal circumstances, F# functions can be converted to delegates by calling new DelegateType and passing in the function as an argument. But when the delegate contains byref parameter, this is not possible directly. For example the code: type ActionByRef<'a> = delegate of 'a byref -> unit let f (x:double byref) = x <- 6.0 let x = ref 42.0 let d = new ActionByRef<_>(f) won't compile, giving the following error: This function value is being used to construct a delegate type whose

Does passing Reference Types using ref save memory?

删除回忆录丶 提交于 2019-12-19 06:21:48
问题 In C#, the parameters to a method can be either reference types or value types. When passing reference types, a copy of the reference is passed. This way, if inside a method we try to reassign the passed reference to another object instance, outside of the method the reassignment is not visible. To make this working, C# has the ref modifier. Passing a reference type with ref actually uses the original reference instead of a copy. (Correct me if I'm wrong). In this case, since we are not

F# member constraints + ^a byref parameters

左心房为你撑大大i 提交于 2019-12-18 04:51:11
问题 After some playing around F# member constraints feature and writing function like this: let inline parse< ^a when ^a : (static member Parse: string -> ^a) > s = (^a: (static member Parse: string -> ^a) s) That works perfectly fine: let xs = [ "123"; "456"; "999" ] |> List.map parse<int> I'm trying to write other func tryParse , that uses static method TryParse and wraps the parse result into 'a option type for better support in F#. Something like this doesn't compiles: let inline tryParse s =

“ref” keyword and reference types [duplicate]

吃可爱长大的小学妹 提交于 2019-12-17 21:05:08
问题 This question already has answers here : What is the use of “ref” for reference-type variables in C#? (10 answers) Closed 6 years ago . someone in my team stumbled upon a peculiar use of the ref keyword on a reference type class A { /* ... */ } class B { public void DoSomething(ref A myObject) { // ... } } Is there any reason someone sane would do such a thing? I can't find a use for this in C# 回答1: Let class A { public string Blah { get; set; } } void Do (ref A a) { a = new A { Blah = "Bar"

PL/SQL print out ref cursor returned by a stored procedure

折月煮酒 提交于 2019-12-17 09:19:34
问题 How can I fetch from a ref cursor that is returned from a stored procedure (OUT variable) and print the resulting rows to STDOUT in SQL*PLUS? ORACLE stored procedure: PROCEDURE GetGrantListByPI(p_firstname IN VARCHAR2, p_lastname IN VARCHAR2, p_orderby IN VARCHAR2, p_cursor OUT grantcur); PL/SQL: SET SERVEROUTPUT ON; DECLARE TYPE r_cursor IS REF CURSOR; refCursor r_cursor; CURSOR grantCursor IS SELECT last_name, first_name FROM ten_year_pis WHERE year_added = 2010; last_name VARCHAR2(100);

Why is list when passed without ref to a function acting like passed with ref?

江枫思渺然 提交于 2019-12-17 07:47:43
问题 If I did not get this terribly wrong, this behaviour is strange for me. Rather than explaining, I'll post a sample code below and please tell me why does I get output x and not y. private void button1_Click(object sender, EventArgs e) { List<int> l = new List<int>() { 1, 2, 3 }; Fuss(l); MessageBox.Show(l.Count.ToString()); } private void Fuss(List<int> l) { l.Add(4); l.Add(5); } Output should, I assume would be 3. But I get the output as 5. I understand the output can be 5 if I do this:

How to properly reference local resources in HTML?

[亡魂溺海] 提交于 2019-12-17 05:38:27
问题 As it turns out, referencing local resources can be a rub point for some. I'm looking for a canonical answer to local resource referencing, and what they mean. Take these examples, what is the difference between these reference paths? <img src="myfile.png" /> (no leading slash) <img src="/myfile.png" /> (with leading slash) <img src="folder/myfile.png" /> (no leading slash / in subfolder) <img src="/folder/myfile.png" /> (with leading slash / in sub folder) <img src="../folder/myfile.png" />

How to properly reference local resources in HTML?

别说谁变了你拦得住时间么 提交于 2019-12-17 05:37:42
问题 As it turns out, referencing local resources can be a rub point for some. I'm looking for a canonical answer to local resource referencing, and what they mean. Take these examples, what is the difference between these reference paths? <img src="myfile.png" /> (no leading slash) <img src="/myfile.png" /> (with leading slash) <img src="folder/myfile.png" /> (no leading slash / in subfolder) <img src="/folder/myfile.png" /> (with leading slash / in sub folder) <img src="../folder/myfile.png" />

Vue JS 2 table title Scroll horizontally with content but not vertically

六眼飞鱼酱① 提交于 2019-12-14 03:57:57
问题 First off in plain Html+css and no JS this is pretty easy to do : table { border-collapse: collapse; } tr { border: solid black 1px; } td{ border: solid black 1px; } .outer-container { height: 190px; width: 620px; } .inner-container { width: 100%; height: 100%; } .table-header { width: 100%; overflow:hidden; } .table-body { height: 100%; width: inherit; overflow-y: scroll; } .col1, .col2, .col3, .col4, .col5 { width:320px; min-width: 320px; } <body> <div class="outer-container"> <!-- absolute

Kivy hyperlink in kv file

有些话、适合烂在心里 提交于 2019-12-13 05:14:35
问题 I am making a mockup of an app just for testing purposes. I am new to kivy and need some help. I want my label to have the text 'Need Help' and when pressed on want it to act as a hyper link. I have a simple class class LoginScreen(BoxLayout): def login(self, *args): print 'You logged in' The part of my kv file I am having trouble with is the label in my LoginScreen. Label: id: need_help_link font_size: 20 markup: True text: 'Need help [ref=some]someweblink[/ref]' I want the label to read