|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Warp wrote:
> Mike Raiford <"m[raiford]!at"@gmail.com> wrote:
>> Transparently.
>
>> e.g.
>
>> delegate void myDel(int x);
>
>> class SomeClass
>> {
>> public int myValue;
>
>> public void DoInstanceStuff(int x)
>> {
>> myValue = x;
>> }
>
>> public static void Main()
>> {
>> SomeClass c = new SomeClass();
>
>> myDel d = c.DoInstanceStuff
>
>> d(6); // this sets c.myValue to 6;
>
>> }
>> }
>
> So you can't use the same function delegate for calling a member
> function of two different objects?
>
No, I don't think you can. The closest you could get would be something
like a multicast delegate. But, then you really cannot get a return value.
--
~Mike
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Warp escreveu:
> nemesis <nam### [at] gmailcom> wrote:
>> But that's within a function composition environment.
>
> Ah, so we avoid being related to the dreaded Object-Oriented Programming
> (vade retro) by using different terminology for the same things. Then we
> can write long lists of reasons why *our* terms do not *really* mean the
> same things as the equivalent OOP terms.
Not that. I have no problem calling ADTs objects or parametrized
regions of code subroutines, functions, procedures, methods or whatever,
as long as it's not within a OO framework. I like functional
programming fluidity and lack of bureaucracy.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Orchid XP v8 wrote:
>> This is how the mechanisms for querying SQL from C# work - you can
>> write something like
>> db.table["customers"].select(x => x.Name > "Henry")
>> and the "select()" function takes the AST describing that condition,
>> translates it to SQL, and sends it to the database.
>
> Lisp would be proud.
>
> Does this transformation happen at compile-time or runtime?
>
Runtime, I believe. The select extension function for the IQueryable
interface takes an expression as its parameter. That expression object
is whats used to build the expression tree. LinqToSQL uses that to build
the SQL query.
--
~Mike
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
nemesis <nam### [at] gmailcom> wrote:
> Not that. I have no problem calling ADTs objects or parametrized
> regions of code subroutines, functions, procedures, methods or whatever,
> as long as it's not within a OO framework. I like functional
> programming fluidity and lack of bureaucracy.
Well, I usually prefer encapsulation and abstraction over fancy
one-liners.
--
- Warp
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Warp escreveu:
> nemesis <nam### [at] gmailcom> wrote:
>> Not that. I have no problem calling ADTs objects or parametrized
>> regions of code subroutines, functions, procedures, methods or whatever,
>> as long as it's not within a OO framework. I like functional
>> programming fluidity and lack of bureaucracy.
>
> Well, I usually prefer encapsulation and abstraction over fancy
> one-liners.
encapsulation and abstraction are conserved, thanks. :)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
nemesis <nam### [at] gmailcom> wrote:
> Warp escreveu:
> > nemesis <nam### [at] gmailcom> wrote:
> >> Not that. I have no problem calling ADTs objects or parametrized
> >> regions of code subroutines, functions, procedures, methods or whatever,
> >> as long as it's not within a OO framework. I like functional
> >> programming fluidity and lack of bureaucracy.
> >
> > Well, I usually prefer encapsulation and abstraction over fancy
> > one-liners.
> encapsulation and abstraction are conserved, thanks. :)
So you take what's great about OOP, rename it, and then say you hate OOP
and that it sucks, and that your own version is so much better.
--
- Warp
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Orchid XP v8 wrote:
> Darren New wrote:
>> Technically, I would think you could have a curried function in a
>> language with named parameters pretty easily.
>
> Yeah, I don't see why not. It's only a shortcut for creating a closure...
I mean, if you have named parameters, it would seem pretty easy to have a
syntax for currying on any parameter.
>> That's where they're used in C#.
> I didn't think C# had curried functions like my example.
Yeah. Brain-oh. It does have closures, tho. Isn't that a very similar thing?
> Does this transformation happen at compile-time or runtime?
As far as I understand it, the AST is generated at compile time, but you can
compile it into actual machine code at runtime.
--
Darren New, San Diego CA, USA (PST)
"Ouch ouch ouch!"
"What's wrong? Noodles too hot?"
"No, I have Chopstick Tunnel Syndrome."
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Warp wrote:
> What if you want to call the function (through the pointer) for different
> objects?
I can't think of a convenient way offhand to do this in C#. I think here
you'd likely fall back to a fixed-named function and then subclass objects
(or inherit from interfaces) to do that.
I never found the need to orthogonally specify a function and an object to
call it on, altho I imagine it might come up sometimes.
--
Darren New, San Diego CA, USA (PST)
"Ouch ouch ouch!"
"What's wrong? Noodles too hot?"
"No, I have Chopstick Tunnel Syndrome."
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Warp wrote:
> So you take what's great about OOP, rename it, and then say you hate OOP
> and that it sucks, and that your own version is so much better.
The way code flows, yes, it's much better.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Mike Raiford wrote:
> No, I don't think you can. The closest you could get would be something
> like a multicast delegate. But, then you really cannot get a return value.
I think you'd have to do something like this. First, you need an interface
that defines all the possible functions you can call this way. That would be
the equivalent of making all the objects subclasses of the same class in C++.
interface Istuff {
int xyz(int x);
int pdq(int x);
}
// Then a class that inherits from Istuff
class Mine : Istuff {
int xyz(int x) { return x + 1; }
int pdq(int x) { return x - 1; }
}
// Declare the type of a delegate that takes the object and integer and runs
something.
delegate int do_it(Istuff on_what, int with_what);
// Declare two delegates, initializing them. One calls xyz, one calls pdq.
do_it use_xyz = ((Istuff on_what, int with_what) => on_what.xyz(with_what));
do_it use_pdq = ((Istuff on_what, int with_what) => on_what.pdq(with_what));
// Pick which one you want
void go_run_a_function(
inputted_bool ? use_xyz : use_pdq,
Istuff some_object, int parameter);
So, you can do it, basically by changing
blah(object, parameter)
into
object.blah(parameter)
with a lambda. But it's messy. Probably about as messy as going the other
way in C++. There's probably some fancy thing with generics you could do too.
--
Darren New, San Diego CA, USA (PST)
"Ouch ouch ouch!"
"What's wrong? Noodles too hot?"
"No, I have Chopstick Tunnel Syndrome."
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |