From purpleidea at gmail.com Thu May 23 20:55:56 2019 From: purpleidea at gmail.com (James) Date: Thu, 23 May 2019 16:55:56 -0400 Subject: [mgmt] Function Values Design Message-ID: I'm currently working on implementing function _values_ in mgmt. You might like to think of these as lambdas. I came across an interesting edge case, and I figured I would post it here for discussion. I have not yet decided which approach I will take, but I might do so shortly. Comments welcome now, or you'll forever have to live with the decision ;) Look at the following mgmt code: import "fmt" # this is a lambda $add = func($x) { # the plus operator can be used for concat # of strings, or addition of numbers $x + $x } $num = 2 $out1 = $add($num) # 4 test fmt.printf("%d + %d is %d", $num, $num, $out1) {} # simple math $val = "hello" $out2 = $add($val) # hellohello test fmt.printf("%s + %s is %s", $val, $val, $out2) {} # simple concat Question! Should the above code compile or not? Before I explain _my_ reasoning for yes or no, I'd love to hear your comments. I'm avoiding elaborating on this, because I don't want to influence your decision. Happy Hacking, James -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: This is a digitally signed message part URL: