Term for function parameters defined for generic use, not specific
Is there a term for this technique? One prominent example is the WinAPI: SendMessage( hwnd, msg, info1, info2 )
where parameters #3 and #4 only make sense per msg
(which also means there are cases when only one or none of those two parameters are needed). See MSDN.
Rephrased: having an all-purpose function that always accepts multiple arguments, but interpreting them depends on a previous argument. I don't want to talk about open arrays, open arguments, typeless arguments... I know all that. That's not what I'm asking - I want to have the term for this type of functions (any maybe also how unspecific parameters are called).
This is not about casts or passing by reference - the parameter types are always the same. Other example: calculate( char operation, int a, int b )
which is then used as
calculate( '+', 2, 5 )
(parameters #2 and #3 are summands)
calculate( '/', 4, 2 )
(parameter #2 is the divident and parameter #3 is the divisor)
calculate( '!', 3, 0 )
(parameter #2 is the factorial and parameter #3 is unused)
In all these cases the data type is always the same and never casted. But the meaning of parameters #2 and #3 differ per parameter #1. And since this is the case it is difficult to give those parameters a meaningful name. Of course the function itself most likely uses a switch(), but that is not subject to my question. How are parameters #2 and #3 called, where a distinct name cannot be found, but data types are always the same?
function parameters
add a comment |
Is there a term for this technique? One prominent example is the WinAPI: SendMessage( hwnd, msg, info1, info2 )
where parameters #3 and #4 only make sense per msg
(which also means there are cases when only one or none of those two parameters are needed). See MSDN.
Rephrased: having an all-purpose function that always accepts multiple arguments, but interpreting them depends on a previous argument. I don't want to talk about open arrays, open arguments, typeless arguments... I know all that. That's not what I'm asking - I want to have the term for this type of functions (any maybe also how unspecific parameters are called).
This is not about casts or passing by reference - the parameter types are always the same. Other example: calculate( char operation, int a, int b )
which is then used as
calculate( '+', 2, 5 )
(parameters #2 and #3 are summands)
calculate( '/', 4, 2 )
(parameter #2 is the divident and parameter #3 is the divisor)
calculate( '!', 3, 0 )
(parameter #2 is the factorial and parameter #3 is unused)
In all these cases the data type is always the same and never casted. But the meaning of parameters #2 and #3 differ per parameter #1. And since this is the case it is difficult to give those parameters a meaningful name. Of course the function itself most likely uses a switch(), but that is not subject to my question. How are parameters #2 and #3 called, where a distinct name cannot be found, but data types are always the same?
function parameters
For clarity, are you referring to Optional Arguments. Which can be used for overloaded functions.
– Nkosi
Nov 27 '18 at 22:22
In the linked example however, those arguments are required and must be provided when ever that function is invoked. If not relevant to the passed msg then it is defaulted. as demonstrated here search forSendMessage
– Nkosi
Nov 27 '18 at 22:35
No, neither overloaded functions (which could all have their own name/type per parameter and amount of parameters) nor optional arguments (it's about the alternating sense of the parameters, not being mandatory/optional)
– AmigoJack
Nov 28 '18 at 7:26
add a comment |
Is there a term for this technique? One prominent example is the WinAPI: SendMessage( hwnd, msg, info1, info2 )
where parameters #3 and #4 only make sense per msg
(which also means there are cases when only one or none of those two parameters are needed). See MSDN.
Rephrased: having an all-purpose function that always accepts multiple arguments, but interpreting them depends on a previous argument. I don't want to talk about open arrays, open arguments, typeless arguments... I know all that. That's not what I'm asking - I want to have the term for this type of functions (any maybe also how unspecific parameters are called).
This is not about casts or passing by reference - the parameter types are always the same. Other example: calculate( char operation, int a, int b )
which is then used as
calculate( '+', 2, 5 )
(parameters #2 and #3 are summands)
calculate( '/', 4, 2 )
(parameter #2 is the divident and parameter #3 is the divisor)
calculate( '!', 3, 0 )
(parameter #2 is the factorial and parameter #3 is unused)
In all these cases the data type is always the same and never casted. But the meaning of parameters #2 and #3 differ per parameter #1. And since this is the case it is difficult to give those parameters a meaningful name. Of course the function itself most likely uses a switch(), but that is not subject to my question. How are parameters #2 and #3 called, where a distinct name cannot be found, but data types are always the same?
function parameters
Is there a term for this technique? One prominent example is the WinAPI: SendMessage( hwnd, msg, info1, info2 )
where parameters #3 and #4 only make sense per msg
(which also means there are cases when only one or none of those two parameters are needed). See MSDN.
Rephrased: having an all-purpose function that always accepts multiple arguments, but interpreting them depends on a previous argument. I don't want to talk about open arrays, open arguments, typeless arguments... I know all that. That's not what I'm asking - I want to have the term for this type of functions (any maybe also how unspecific parameters are called).
This is not about casts or passing by reference - the parameter types are always the same. Other example: calculate( char operation, int a, int b )
which is then used as
calculate( '+', 2, 5 )
(parameters #2 and #3 are summands)
calculate( '/', 4, 2 )
(parameter #2 is the divident and parameter #3 is the divisor)
calculate( '!', 3, 0 )
(parameter #2 is the factorial and parameter #3 is unused)
In all these cases the data type is always the same and never casted. But the meaning of parameters #2 and #3 differ per parameter #1. And since this is the case it is difficult to give those parameters a meaningful name. Of course the function itself most likely uses a switch(), but that is not subject to my question. How are parameters #2 and #3 called, where a distinct name cannot be found, but data types are always the same?
function parameters
function parameters
edited Dec 6 '18 at 14:16
AmigoJack
asked Nov 21 '18 at 8:37
AmigoJackAmigoJack
622414
622414
For clarity, are you referring to Optional Arguments. Which can be used for overloaded functions.
– Nkosi
Nov 27 '18 at 22:22
In the linked example however, those arguments are required and must be provided when ever that function is invoked. If not relevant to the passed msg then it is defaulted. as demonstrated here search forSendMessage
– Nkosi
Nov 27 '18 at 22:35
No, neither overloaded functions (which could all have their own name/type per parameter and amount of parameters) nor optional arguments (it's about the alternating sense of the parameters, not being mandatory/optional)
– AmigoJack
Nov 28 '18 at 7:26
add a comment |
For clarity, are you referring to Optional Arguments. Which can be used for overloaded functions.
– Nkosi
Nov 27 '18 at 22:22
In the linked example however, those arguments are required and must be provided when ever that function is invoked. If not relevant to the passed msg then it is defaulted. as demonstrated here search forSendMessage
– Nkosi
Nov 27 '18 at 22:35
No, neither overloaded functions (which could all have their own name/type per parameter and amount of parameters) nor optional arguments (it's about the alternating sense of the parameters, not being mandatory/optional)
– AmigoJack
Nov 28 '18 at 7:26
For clarity, are you referring to Optional Arguments. Which can be used for overloaded functions.
– Nkosi
Nov 27 '18 at 22:22
For clarity, are you referring to Optional Arguments. Which can be used for overloaded functions.
– Nkosi
Nov 27 '18 at 22:22
In the linked example however, those arguments are required and must be provided when ever that function is invoked. If not relevant to the passed msg then it is defaulted. as demonstrated here search for
SendMessage
– Nkosi
Nov 27 '18 at 22:35
In the linked example however, those arguments are required and must be provided when ever that function is invoked. If not relevant to the passed msg then it is defaulted. as demonstrated here search for
SendMessage
– Nkosi
Nov 27 '18 at 22:35
No, neither overloaded functions (which could all have their own name/type per parameter and amount of parameters) nor optional arguments (it's about the alternating sense of the parameters, not being mandatory/optional)
– AmigoJack
Nov 28 '18 at 7:26
No, neither overloaded functions (which could all have their own name/type per parameter and amount of parameters) nor optional arguments (it's about the alternating sense of the parameters, not being mandatory/optional)
– AmigoJack
Nov 28 '18 at 7:26
add a comment |
3 Answers
3
active
oldest
votes
The fact the msg argument "changes" the parameters is through a simple switch statement. Each "msg" in the switch knows the parameters(with type) needed and casts them appropriately.
This "technique" is called passing by reference, or passing by address. The latter is usually used for method pointers.
There is no Special name if that is what you are asking. It is a regular function, method or procedure.
The referenced Function is a Win32 API Function, which may be referred to as a "Windows function call."
Yes, with the WinAPI example this is true, yet still information I never asked for. Calling by reference is wrong, as I can very well call it with literals/constants, not only variables. I'd call parameters #3 and #4 "dependant", but that ignores that they're not automatically subject to casts and different types. I'm gonna edit my question to add another example.
– AmigoJack
Dec 6 '18 at 14:01
add a comment |
This is an example of a static Parameter and multiple Dynamic parameters.
The static is the "msg" and the dynamic is described as the following:
These parameters are generic pointers. Passed by reference. They can point to any data type or no value, ie null pointer. It is up to the sender to lock the memory in place, and the receiving method to interpret the pointer correctly (through pointer casts).
This is an example of typeless argument passing. The only thing passed is a memory address. It is dangerous since the types passed must be agreed upon ahead of time(by convention and not contract as with a typed language construct) and must match on both sides of the call.
This was common before C++, in the C days, we only had C structs to pass around. Leading to many General Fault Protection errors. Since then, typed interfaces mostly have replaced the generic equivalents through libraries. But the underlying Win32 methods remain the same. The main substantial change since its' inception is the acceptance of 64-bit pointers.
That's almost completely missing my question: the data type of the arguments are not the issue - let them be the same for every call (instead of pointers) - could you then name a term for this technique?
– AmigoJack
Dec 1 '18 at 22:34
Please don't downvote this, as it explains how the diverse parameters are passed. While this may not be germane to the OP, It is correct and should be preserved for all who come later.
– Strom
Dec 3 '18 at 3:35
This is why I opened a new answer instead of editing this one.
– Strom
Dec 3 '18 at 3:36
There are rarily question where providing ANY true information is wanted, and this one isn't - hence the downvote.
– AmigoJack
Dec 6 '18 at 14:04
add a comment |
Although not widely supported, what you are referring to would be a dependently typed function (or dependently typed parameters).
To quote wikipedia on dependent types
A "pair of integers" is a type. A "pair of integers where the second is greater than the first" is a dependent type because of the dependence on the value.
The parameters could have a type that depends on a value. The type of info1
depends on the value msg
as does info2
.
In order to make this approach work in a language without dependent types, the dependent parameters are given a very generic type that is only refined later on when more information is available. When the type of msg
becomes known (at runtime) only then is are the types of info1
and info2
assumed. Even though the language doesn't allow you to express this dependency, I would still call the approach a dependently type one.
@Storm Yes it is hard to talk about in this context as the function isn't curried but mapping from this uncurried context, these last parameters would be dependent. Currying the function is trivial in this example as theinfo
parameters are last. I don't think there is anything new here, they are return types in the curried definition, parameter types in this one.
– SpencerPark
Dec 5 '18 at 0:23
The reference equates the return value as the "Dependent type"; and does not reference the modification of previous arguments. I believe you may have coined a new usage for the term. I hope it catches on.
– Strom
Dec 5 '18 at 0:25
I am familiar with LISP, Scheme, and Haskell, as well as C and C++. The term Curry does not apply here since C does not reduce its parameters to single element forms. Parameter order is irrelevant in C method calls. There is no composition.
– Strom
Dec 5 '18 at 0:48
Good point (and TIL in C arguments aren't evaluated left to right, thanks!), what I meant was that it is the closest we can come to the metaphor. In a language with curried functions there is no need to talk about a "dependently typed parameter" because it is actually part of the return type of the returned function. When stretching it to something like C this term seems to capture the idea but you are right, it doesn't make sense to mentally curry the signature.
– SpencerPark
Dec 5 '18 at 4:17
I agree with your analogy. But until it is accepted as common terminology in the area referenced, C/C++ and Windows API, it cannot be treated as such. If I were to walk into a room full of professors and professionals, in the field, how many of the would know your term, as it applies in this context? Publish a paper make it well known.
– Strom
Dec 5 '18 at 5:28
|
show 3 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408078%2fterm-for-function-parameters-defined-for-generic-use-not-specific%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
The fact the msg argument "changes" the parameters is through a simple switch statement. Each "msg" in the switch knows the parameters(with type) needed and casts them appropriately.
This "technique" is called passing by reference, or passing by address. The latter is usually used for method pointers.
There is no Special name if that is what you are asking. It is a regular function, method or procedure.
The referenced Function is a Win32 API Function, which may be referred to as a "Windows function call."
Yes, with the WinAPI example this is true, yet still information I never asked for. Calling by reference is wrong, as I can very well call it with literals/constants, not only variables. I'd call parameters #3 and #4 "dependant", but that ignores that they're not automatically subject to casts and different types. I'm gonna edit my question to add another example.
– AmigoJack
Dec 6 '18 at 14:01
add a comment |
The fact the msg argument "changes" the parameters is through a simple switch statement. Each "msg" in the switch knows the parameters(with type) needed and casts them appropriately.
This "technique" is called passing by reference, or passing by address. The latter is usually used for method pointers.
There is no Special name if that is what you are asking. It is a regular function, method or procedure.
The referenced Function is a Win32 API Function, which may be referred to as a "Windows function call."
Yes, with the WinAPI example this is true, yet still information I never asked for. Calling by reference is wrong, as I can very well call it with literals/constants, not only variables. I'd call parameters #3 and #4 "dependant", but that ignores that they're not automatically subject to casts and different types. I'm gonna edit my question to add another example.
– AmigoJack
Dec 6 '18 at 14:01
add a comment |
The fact the msg argument "changes" the parameters is through a simple switch statement. Each "msg" in the switch knows the parameters(with type) needed and casts them appropriately.
This "technique" is called passing by reference, or passing by address. The latter is usually used for method pointers.
There is no Special name if that is what you are asking. It is a regular function, method or procedure.
The referenced Function is a Win32 API Function, which may be referred to as a "Windows function call."
The fact the msg argument "changes" the parameters is through a simple switch statement. Each "msg" in the switch knows the parameters(with type) needed and casts them appropriately.
This "technique" is called passing by reference, or passing by address. The latter is usually used for method pointers.
There is no Special name if that is what you are asking. It is a regular function, method or procedure.
The referenced Function is a Win32 API Function, which may be referred to as a "Windows function call."
edited Dec 3 '18 at 6:37
answered Dec 3 '18 at 0:41
StromStrom
2,423524
2,423524
Yes, with the WinAPI example this is true, yet still information I never asked for. Calling by reference is wrong, as I can very well call it with literals/constants, not only variables. I'd call parameters #3 and #4 "dependant", but that ignores that they're not automatically subject to casts and different types. I'm gonna edit my question to add another example.
– AmigoJack
Dec 6 '18 at 14:01
add a comment |
Yes, with the WinAPI example this is true, yet still information I never asked for. Calling by reference is wrong, as I can very well call it with literals/constants, not only variables. I'd call parameters #3 and #4 "dependant", but that ignores that they're not automatically subject to casts and different types. I'm gonna edit my question to add another example.
– AmigoJack
Dec 6 '18 at 14:01
Yes, with the WinAPI example this is true, yet still information I never asked for. Calling by reference is wrong, as I can very well call it with literals/constants, not only variables. I'd call parameters #3 and #4 "dependant", but that ignores that they're not automatically subject to casts and different types. I'm gonna edit my question to add another example.
– AmigoJack
Dec 6 '18 at 14:01
Yes, with the WinAPI example this is true, yet still information I never asked for. Calling by reference is wrong, as I can very well call it with literals/constants, not only variables. I'd call parameters #3 and #4 "dependant", but that ignores that they're not automatically subject to casts and different types. I'm gonna edit my question to add another example.
– AmigoJack
Dec 6 '18 at 14:01
add a comment |
This is an example of a static Parameter and multiple Dynamic parameters.
The static is the "msg" and the dynamic is described as the following:
These parameters are generic pointers. Passed by reference. They can point to any data type or no value, ie null pointer. It is up to the sender to lock the memory in place, and the receiving method to interpret the pointer correctly (through pointer casts).
This is an example of typeless argument passing. The only thing passed is a memory address. It is dangerous since the types passed must be agreed upon ahead of time(by convention and not contract as with a typed language construct) and must match on both sides of the call.
This was common before C++, in the C days, we only had C structs to pass around. Leading to many General Fault Protection errors. Since then, typed interfaces mostly have replaced the generic equivalents through libraries. But the underlying Win32 methods remain the same. The main substantial change since its' inception is the acceptance of 64-bit pointers.
That's almost completely missing my question: the data type of the arguments are not the issue - let them be the same for every call (instead of pointers) - could you then name a term for this technique?
– AmigoJack
Dec 1 '18 at 22:34
Please don't downvote this, as it explains how the diverse parameters are passed. While this may not be germane to the OP, It is correct and should be preserved for all who come later.
– Strom
Dec 3 '18 at 3:35
This is why I opened a new answer instead of editing this one.
– Strom
Dec 3 '18 at 3:36
There are rarily question where providing ANY true information is wanted, and this one isn't - hence the downvote.
– AmigoJack
Dec 6 '18 at 14:04
add a comment |
This is an example of a static Parameter and multiple Dynamic parameters.
The static is the "msg" and the dynamic is described as the following:
These parameters are generic pointers. Passed by reference. They can point to any data type or no value, ie null pointer. It is up to the sender to lock the memory in place, and the receiving method to interpret the pointer correctly (through pointer casts).
This is an example of typeless argument passing. The only thing passed is a memory address. It is dangerous since the types passed must be agreed upon ahead of time(by convention and not contract as with a typed language construct) and must match on both sides of the call.
This was common before C++, in the C days, we only had C structs to pass around. Leading to many General Fault Protection errors. Since then, typed interfaces mostly have replaced the generic equivalents through libraries. But the underlying Win32 methods remain the same. The main substantial change since its' inception is the acceptance of 64-bit pointers.
That's almost completely missing my question: the data type of the arguments are not the issue - let them be the same for every call (instead of pointers) - could you then name a term for this technique?
– AmigoJack
Dec 1 '18 at 22:34
Please don't downvote this, as it explains how the diverse parameters are passed. While this may not be germane to the OP, It is correct and should be preserved for all who come later.
– Strom
Dec 3 '18 at 3:35
This is why I opened a new answer instead of editing this one.
– Strom
Dec 3 '18 at 3:36
There are rarily question where providing ANY true information is wanted, and this one isn't - hence the downvote.
– AmigoJack
Dec 6 '18 at 14:04
add a comment |
This is an example of a static Parameter and multiple Dynamic parameters.
The static is the "msg" and the dynamic is described as the following:
These parameters are generic pointers. Passed by reference. They can point to any data type or no value, ie null pointer. It is up to the sender to lock the memory in place, and the receiving method to interpret the pointer correctly (through pointer casts).
This is an example of typeless argument passing. The only thing passed is a memory address. It is dangerous since the types passed must be agreed upon ahead of time(by convention and not contract as with a typed language construct) and must match on both sides of the call.
This was common before C++, in the C days, we only had C structs to pass around. Leading to many General Fault Protection errors. Since then, typed interfaces mostly have replaced the generic equivalents through libraries. But the underlying Win32 methods remain the same. The main substantial change since its' inception is the acceptance of 64-bit pointers.
This is an example of a static Parameter and multiple Dynamic parameters.
The static is the "msg" and the dynamic is described as the following:
These parameters are generic pointers. Passed by reference. They can point to any data type or no value, ie null pointer. It is up to the sender to lock the memory in place, and the receiving method to interpret the pointer correctly (through pointer casts).
This is an example of typeless argument passing. The only thing passed is a memory address. It is dangerous since the types passed must be agreed upon ahead of time(by convention and not contract as with a typed language construct) and must match on both sides of the call.
This was common before C++, in the C days, we only had C structs to pass around. Leading to many General Fault Protection errors. Since then, typed interfaces mostly have replaced the generic equivalents through libraries. But the underlying Win32 methods remain the same. The main substantial change since its' inception is the acceptance of 64-bit pointers.
edited Dec 3 '18 at 4:33
answered Dec 1 '18 at 3:26
StromStrom
2,423524
2,423524
That's almost completely missing my question: the data type of the arguments are not the issue - let them be the same for every call (instead of pointers) - could you then name a term for this technique?
– AmigoJack
Dec 1 '18 at 22:34
Please don't downvote this, as it explains how the diverse parameters are passed. While this may not be germane to the OP, It is correct and should be preserved for all who come later.
– Strom
Dec 3 '18 at 3:35
This is why I opened a new answer instead of editing this one.
– Strom
Dec 3 '18 at 3:36
There are rarily question where providing ANY true information is wanted, and this one isn't - hence the downvote.
– AmigoJack
Dec 6 '18 at 14:04
add a comment |
That's almost completely missing my question: the data type of the arguments are not the issue - let them be the same for every call (instead of pointers) - could you then name a term for this technique?
– AmigoJack
Dec 1 '18 at 22:34
Please don't downvote this, as it explains how the diverse parameters are passed. While this may not be germane to the OP, It is correct and should be preserved for all who come later.
– Strom
Dec 3 '18 at 3:35
This is why I opened a new answer instead of editing this one.
– Strom
Dec 3 '18 at 3:36
There are rarily question where providing ANY true information is wanted, and this one isn't - hence the downvote.
– AmigoJack
Dec 6 '18 at 14:04
That's almost completely missing my question: the data type of the arguments are not the issue - let them be the same for every call (instead of pointers) - could you then name a term for this technique?
– AmigoJack
Dec 1 '18 at 22:34
That's almost completely missing my question: the data type of the arguments are not the issue - let them be the same for every call (instead of pointers) - could you then name a term for this technique?
– AmigoJack
Dec 1 '18 at 22:34
Please don't downvote this, as it explains how the diverse parameters are passed. While this may not be germane to the OP, It is correct and should be preserved for all who come later.
– Strom
Dec 3 '18 at 3:35
Please don't downvote this, as it explains how the diverse parameters are passed. While this may not be germane to the OP, It is correct and should be preserved for all who come later.
– Strom
Dec 3 '18 at 3:35
This is why I opened a new answer instead of editing this one.
– Strom
Dec 3 '18 at 3:36
This is why I opened a new answer instead of editing this one.
– Strom
Dec 3 '18 at 3:36
There are rarily question where providing ANY true information is wanted, and this one isn't - hence the downvote.
– AmigoJack
Dec 6 '18 at 14:04
There are rarily question where providing ANY true information is wanted, and this one isn't - hence the downvote.
– AmigoJack
Dec 6 '18 at 14:04
add a comment |
Although not widely supported, what you are referring to would be a dependently typed function (or dependently typed parameters).
To quote wikipedia on dependent types
A "pair of integers" is a type. A "pair of integers where the second is greater than the first" is a dependent type because of the dependence on the value.
The parameters could have a type that depends on a value. The type of info1
depends on the value msg
as does info2
.
In order to make this approach work in a language without dependent types, the dependent parameters are given a very generic type that is only refined later on when more information is available. When the type of msg
becomes known (at runtime) only then is are the types of info1
and info2
assumed. Even though the language doesn't allow you to express this dependency, I would still call the approach a dependently type one.
@Storm Yes it is hard to talk about in this context as the function isn't curried but mapping from this uncurried context, these last parameters would be dependent. Currying the function is trivial in this example as theinfo
parameters are last. I don't think there is anything new here, they are return types in the curried definition, parameter types in this one.
– SpencerPark
Dec 5 '18 at 0:23
The reference equates the return value as the "Dependent type"; and does not reference the modification of previous arguments. I believe you may have coined a new usage for the term. I hope it catches on.
– Strom
Dec 5 '18 at 0:25
I am familiar with LISP, Scheme, and Haskell, as well as C and C++. The term Curry does not apply here since C does not reduce its parameters to single element forms. Parameter order is irrelevant in C method calls. There is no composition.
– Strom
Dec 5 '18 at 0:48
Good point (and TIL in C arguments aren't evaluated left to right, thanks!), what I meant was that it is the closest we can come to the metaphor. In a language with curried functions there is no need to talk about a "dependently typed parameter" because it is actually part of the return type of the returned function. When stretching it to something like C this term seems to capture the idea but you are right, it doesn't make sense to mentally curry the signature.
– SpencerPark
Dec 5 '18 at 4:17
I agree with your analogy. But until it is accepted as common terminology in the area referenced, C/C++ and Windows API, it cannot be treated as such. If I were to walk into a room full of professors and professionals, in the field, how many of the would know your term, as it applies in this context? Publish a paper make it well known.
– Strom
Dec 5 '18 at 5:28
|
show 3 more comments
Although not widely supported, what you are referring to would be a dependently typed function (or dependently typed parameters).
To quote wikipedia on dependent types
A "pair of integers" is a type. A "pair of integers where the second is greater than the first" is a dependent type because of the dependence on the value.
The parameters could have a type that depends on a value. The type of info1
depends on the value msg
as does info2
.
In order to make this approach work in a language without dependent types, the dependent parameters are given a very generic type that is only refined later on when more information is available. When the type of msg
becomes known (at runtime) only then is are the types of info1
and info2
assumed. Even though the language doesn't allow you to express this dependency, I would still call the approach a dependently type one.
@Storm Yes it is hard to talk about in this context as the function isn't curried but mapping from this uncurried context, these last parameters would be dependent. Currying the function is trivial in this example as theinfo
parameters are last. I don't think there is anything new here, they are return types in the curried definition, parameter types in this one.
– SpencerPark
Dec 5 '18 at 0:23
The reference equates the return value as the "Dependent type"; and does not reference the modification of previous arguments. I believe you may have coined a new usage for the term. I hope it catches on.
– Strom
Dec 5 '18 at 0:25
I am familiar with LISP, Scheme, and Haskell, as well as C and C++. The term Curry does not apply here since C does not reduce its parameters to single element forms. Parameter order is irrelevant in C method calls. There is no composition.
– Strom
Dec 5 '18 at 0:48
Good point (and TIL in C arguments aren't evaluated left to right, thanks!), what I meant was that it is the closest we can come to the metaphor. In a language with curried functions there is no need to talk about a "dependently typed parameter" because it is actually part of the return type of the returned function. When stretching it to something like C this term seems to capture the idea but you are right, it doesn't make sense to mentally curry the signature.
– SpencerPark
Dec 5 '18 at 4:17
I agree with your analogy. But until it is accepted as common terminology in the area referenced, C/C++ and Windows API, it cannot be treated as such. If I were to walk into a room full of professors and professionals, in the field, how many of the would know your term, as it applies in this context? Publish a paper make it well known.
– Strom
Dec 5 '18 at 5:28
|
show 3 more comments
Although not widely supported, what you are referring to would be a dependently typed function (or dependently typed parameters).
To quote wikipedia on dependent types
A "pair of integers" is a type. A "pair of integers where the second is greater than the first" is a dependent type because of the dependence on the value.
The parameters could have a type that depends on a value. The type of info1
depends on the value msg
as does info2
.
In order to make this approach work in a language without dependent types, the dependent parameters are given a very generic type that is only refined later on when more information is available. When the type of msg
becomes known (at runtime) only then is are the types of info1
and info2
assumed. Even though the language doesn't allow you to express this dependency, I would still call the approach a dependently type one.
Although not widely supported, what you are referring to would be a dependently typed function (or dependently typed parameters).
To quote wikipedia on dependent types
A "pair of integers" is a type. A "pair of integers where the second is greater than the first" is a dependent type because of the dependence on the value.
The parameters could have a type that depends on a value. The type of info1
depends on the value msg
as does info2
.
In order to make this approach work in a language without dependent types, the dependent parameters are given a very generic type that is only refined later on when more information is available. When the type of msg
becomes known (at runtime) only then is are the types of info1
and info2
assumed. Even though the language doesn't allow you to express this dependency, I would still call the approach a dependently type one.
answered Dec 4 '18 at 22:19
SpencerParkSpencerPark
545311
545311
@Storm Yes it is hard to talk about in this context as the function isn't curried but mapping from this uncurried context, these last parameters would be dependent. Currying the function is trivial in this example as theinfo
parameters are last. I don't think there is anything new here, they are return types in the curried definition, parameter types in this one.
– SpencerPark
Dec 5 '18 at 0:23
The reference equates the return value as the "Dependent type"; and does not reference the modification of previous arguments. I believe you may have coined a new usage for the term. I hope it catches on.
– Strom
Dec 5 '18 at 0:25
I am familiar with LISP, Scheme, and Haskell, as well as C and C++. The term Curry does not apply here since C does not reduce its parameters to single element forms. Parameter order is irrelevant in C method calls. There is no composition.
– Strom
Dec 5 '18 at 0:48
Good point (and TIL in C arguments aren't evaluated left to right, thanks!), what I meant was that it is the closest we can come to the metaphor. In a language with curried functions there is no need to talk about a "dependently typed parameter" because it is actually part of the return type of the returned function. When stretching it to something like C this term seems to capture the idea but you are right, it doesn't make sense to mentally curry the signature.
– SpencerPark
Dec 5 '18 at 4:17
I agree with your analogy. But until it is accepted as common terminology in the area referenced, C/C++ and Windows API, it cannot be treated as such. If I were to walk into a room full of professors and professionals, in the field, how many of the would know your term, as it applies in this context? Publish a paper make it well known.
– Strom
Dec 5 '18 at 5:28
|
show 3 more comments
@Storm Yes it is hard to talk about in this context as the function isn't curried but mapping from this uncurried context, these last parameters would be dependent. Currying the function is trivial in this example as theinfo
parameters are last. I don't think there is anything new here, they are return types in the curried definition, parameter types in this one.
– SpencerPark
Dec 5 '18 at 0:23
The reference equates the return value as the "Dependent type"; and does not reference the modification of previous arguments. I believe you may have coined a new usage for the term. I hope it catches on.
– Strom
Dec 5 '18 at 0:25
I am familiar with LISP, Scheme, and Haskell, as well as C and C++. The term Curry does not apply here since C does not reduce its parameters to single element forms. Parameter order is irrelevant in C method calls. There is no composition.
– Strom
Dec 5 '18 at 0:48
Good point (and TIL in C arguments aren't evaluated left to right, thanks!), what I meant was that it is the closest we can come to the metaphor. In a language with curried functions there is no need to talk about a "dependently typed parameter" because it is actually part of the return type of the returned function. When stretching it to something like C this term seems to capture the idea but you are right, it doesn't make sense to mentally curry the signature.
– SpencerPark
Dec 5 '18 at 4:17
I agree with your analogy. But until it is accepted as common terminology in the area referenced, C/C++ and Windows API, it cannot be treated as such. If I were to walk into a room full of professors and professionals, in the field, how many of the would know your term, as it applies in this context? Publish a paper make it well known.
– Strom
Dec 5 '18 at 5:28
@Storm Yes it is hard to talk about in this context as the function isn't curried but mapping from this uncurried context, these last parameters would be dependent. Currying the function is trivial in this example as the
info
parameters are last. I don't think there is anything new here, they are return types in the curried definition, parameter types in this one.– SpencerPark
Dec 5 '18 at 0:23
@Storm Yes it is hard to talk about in this context as the function isn't curried but mapping from this uncurried context, these last parameters would be dependent. Currying the function is trivial in this example as the
info
parameters are last. I don't think there is anything new here, they are return types in the curried definition, parameter types in this one.– SpencerPark
Dec 5 '18 at 0:23
The reference equates the return value as the "Dependent type"; and does not reference the modification of previous arguments. I believe you may have coined a new usage for the term. I hope it catches on.
– Strom
Dec 5 '18 at 0:25
The reference equates the return value as the "Dependent type"; and does not reference the modification of previous arguments. I believe you may have coined a new usage for the term. I hope it catches on.
– Strom
Dec 5 '18 at 0:25
I am familiar with LISP, Scheme, and Haskell, as well as C and C++. The term Curry does not apply here since C does not reduce its parameters to single element forms. Parameter order is irrelevant in C method calls. There is no composition.
– Strom
Dec 5 '18 at 0:48
I am familiar with LISP, Scheme, and Haskell, as well as C and C++. The term Curry does not apply here since C does not reduce its parameters to single element forms. Parameter order is irrelevant in C method calls. There is no composition.
– Strom
Dec 5 '18 at 0:48
Good point (and TIL in C arguments aren't evaluated left to right, thanks!), what I meant was that it is the closest we can come to the metaphor. In a language with curried functions there is no need to talk about a "dependently typed parameter" because it is actually part of the return type of the returned function. When stretching it to something like C this term seems to capture the idea but you are right, it doesn't make sense to mentally curry the signature.
– SpencerPark
Dec 5 '18 at 4:17
Good point (and TIL in C arguments aren't evaluated left to right, thanks!), what I meant was that it is the closest we can come to the metaphor. In a language with curried functions there is no need to talk about a "dependently typed parameter" because it is actually part of the return type of the returned function. When stretching it to something like C this term seems to capture the idea but you are right, it doesn't make sense to mentally curry the signature.
– SpencerPark
Dec 5 '18 at 4:17
I agree with your analogy. But until it is accepted as common terminology in the area referenced, C/C++ and Windows API, it cannot be treated as such. If I were to walk into a room full of professors and professionals, in the field, how many of the would know your term, as it applies in this context? Publish a paper make it well known.
– Strom
Dec 5 '18 at 5:28
I agree with your analogy. But until it is accepted as common terminology in the area referenced, C/C++ and Windows API, it cannot be treated as such. If I were to walk into a room full of professors and professionals, in the field, how many of the would know your term, as it applies in this context? Publish a paper make it well known.
– Strom
Dec 5 '18 at 5:28
|
show 3 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408078%2fterm-for-function-parameters-defined-for-generic-use-not-specific%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
For clarity, are you referring to Optional Arguments. Which can be used for overloaded functions.
– Nkosi
Nov 27 '18 at 22:22
In the linked example however, those arguments are required and must be provided when ever that function is invoked. If not relevant to the passed msg then it is defaulted. as demonstrated here search for
SendMessage
– Nkosi
Nov 27 '18 at 22:35
No, neither overloaded functions (which could all have their own name/type per parameter and amount of parameters) nor optional arguments (it's about the alternating sense of the parameters, not being mandatory/optional)
– AmigoJack
Nov 28 '18 at 7:26