Re: Partial function in VB6?
You had me very confused at first as I was thinking "partial methods" and thought that this had nothing to do with that. It does indeed have nothing to do with that, because you're talking about something else entirely. Order restored.
Re: Partial function in VB6?
That looks like generics to me... not partial... which is a completely different thing. Also I don't think you can have partial functions/methods - in any language - partial classes, sure. Methods, no. It wouldn't make sense. Generics though... sure that makes sense. Whether VB6 can do it or not... shrug. I honestly don't know. Never thought about it.
-tg
Re: Partial function in VB6?
Quote:
Originally Posted by
techgnome
That looks like generics to me... not partial... which is a completely different thing. Also I don't think you can have partial functions/methods - in any language - partial classes, sure. Methods, no. It wouldn't make sense. Generics though... sure that makes sense. Whether VB6 can do it or not... shrug. I honestly don't know. Never thought about it.
-tg
Here's an article about partial functions in python:
https://www.udacity.com/blog/2020/12...in-python.html
Re: Partial function in VB6?
Quote:
Originally Posted by
techgnome
That looks like generics to me... not partial... which is a completely different thing. Also I don't think you can have partial functions/methods - in any language - partial classes, sure. Methods, no. It wouldn't make sense. Generics though... sure that makes sense. Whether VB6 can do it or not... shrug. I honestly don't know. Never thought about it.
-tg
I think that you made the same misinterpretation that I did initially. This is nothing to do with partial classes and partial methods. This is a functional programming concept.
Re: Partial function in VB6?
Even getting VB to call a function pointer at all takes some hacks, let alone using it generically.
The closest you could get would be doing everything totally late-bound, with CallByName.
Re: Partial function in VB6?
Quote:
Originally Posted by
dee-u
Here's the python-example expressed in VB6/VBA-code:
Function-def of the "large function" (Pythonstyle) ;)
Code:
Function multiply(x, y)
multiply = x * y: End Function
Function-def of a "manually derived" partial-function (using named parameters, to rule-out mistakes):
Code:
Function times_12(y)
times_12 = multiply(x:=12, y:=y): End Function
TestCode:
Code:
Sub Main()
Debug.Print multiply(6, 7) '42
Debug.Print times_12(2) '24
End Sub
HTH
Olaf
Re: Partial function in VB6?
I must be missing something fundamental, because I don't see a new paradigm in this..
:eek:
Re: Partial function in VB6?
Quote:
Originally Posted by
Arnoutdv
I must be missing something fundamental, because I don't see a new paradigm in this..
:eek:
I'm no expert so I might be missing something but I suspect that that's because it's an attempt to implement a functional programming concept in other than a functional programming language, so it requires stuff we already use and recognise to do something we don't usually try to do. I suspect that what's going on would be clearer in F#.
Re: Partial function in VB6?
Quote:
Originally Posted by
Arnoutdv
I must be missing something fundamental, because I don't see a new paradigm in this..
:eek:
That's probably, because there is none... ;)
Olaf
Re: Partial function in VB6?
To understand currying you have to have first-class functions in the language i.e. being able to assign functions to variables like Dim a As Variant : a = MyFunction is not available in VB6.
Re: Partial function in VB6?
I'm picturing tons of bad code out there that falls apart under maintenance. It uses such "features" by stumble-bum accident and cargo-culting and it works... until later when the house of cards comes down.
It feels like the sort of trash only a script kiddie could love. If it has any value then a distict "assign function pointer" operator should be required.
Algol-60's "call by name" seems far more useful and less problematic and even that used to trip people up a lot. At least a lot of compilers had the option to flag its use in order to help debug misbehaving code.
Re: Partial function in VB6?
Quote:
Originally Posted by
wqweto
To understand
currying you have to have first-class functions in the language i.e. being able to assign functions to variables like Dim a As Variant : a = MyFunction is not available in VB6.
If one really wants to go there, then "doing it the VBScript-way" is certainly feasible:
...by defining a Class with a single default-method in it...
E.g. a Sum(Func)-Definition in a Class, named Sum:
Code:
Public Function Ret(ParamArray Args()) '<- set the Default-Attribute on this method
Ret = Args(0) + Args(1)
End Function
TestCode:
Code:
Sub Main()
Dim Sum As New Sum
Debug.Print Sum(1, 2), Sum(2, 3)
End Sub
A simple "Currying-demo" then requires only an additional Class, named SumCurried:
Code:
Private f As New Sum, m
Public Function Ret(Arg) '<- set the Default-Attribute on this method
If IsEmpty(m) Then
Set Ret = Me
m = Arg
Else
Ret = f(m, Arg)
m = Empty
End If
End Function
TestCode:
Code:
Sub Main()
Dim Sum As New Sum
Debug.Print Sum(1, 2), Sum(2, 3)
Dim CurriedSum As New SumCurried
Debug.Print CurriedSum(1)(2), CurriedSum(2)(3)
End Sub
Olaf
Re: Partial function in VB6?
Partial methods enable developers to insert custom logic into code. Typically, the code is part of a designer-generated class. Partial methods are defined in a partial class that is created by a code generator, and they are commonly used to provide notification that something has been changed. They enable the developer to specify custom behavior in response to the change.
Re: Partial function in VB6?
Quote:
Originally Posted by
mmarkgilbert
Partial methods enable developers to insert custom logic into code. Typically, the code is part of a designer-generated class. Partial methods are defined in a partial class that is created by a code generator, and they are commonly used to provide notification that something has been changed. They enable the developer to specify custom behavior in response to the change.
True but OP is not about partial *methods* per se. Did you read the thread?
cheers,
</wqw>
Re: Partial function in VB6?
Quote:
Originally Posted by
wqweto
True but OP is not about partial *methods* per se. Did you read the thread?
cheers,
</wqw>
Don't bother with this user. If you look at all of their most recent posts, they are straight copy/paste jobs of content from other websites, so I would assume this is some sort of bot.