[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: functions and upvalues
- From: "Wesley Smith" <wesley.hoke@...>
- Date: Thu, 31 May 2007 18:34:52 -0700
Right, I know that this works, but what if I have say 80 parameters.
My solution in the end was to pass tables into the function. I think
a cleaner solution might be to use some kind of class structure as
opposed to global functions like I'm doing now. Anyway, I got the
scoping thing in my head now so I know what doesn't work.
On 5/31/07, Michael Surette <firstname.lastname@example.org> wrote:
On 5/31/07, Wesley Smith <email@example.com> wrote:
> Yes, I could, but image there are 30 or 40 of these functions. The
> constructor would get rather long. The real goal here is to pass in
> functions that describe behaviors to the constructor. Sometimes,
> these behavior functions need data from the constructor itself. I
> guess I could reorganize my constructor to take a table instead of a
> list of values and pass the table into the function instead. That
> way, I can write a small constructor and general functions outside of
> On 5/31/07, Roberto Ierusalimschy <firstname.lastname@example.org> wrote:
> > > What I'd like is f1's val upvalue to refer to constructor's local
> > > variable val. Is this possible somehow through environments?
> > Can't you define 'gen1' inside the constructor?
> > -- Roberto
Here's a simple example of what I believe Roberto is suggesting. It works
well for me. Am I missing something?