Yeah I guess that's not such a bad idea, to have a TemplateClass that would
contain just the template methods, so I don't need to worry about
conflicting instance variables.

Peter

On Tue, Jun 28, 2016 at 2:08 PM, Ben Coman <b...@openinworld.com> wrote:

> On Tue, Jun 28, 2016 at 5:55 PM, Peter Uhnak <i.uh...@gmail.com> wrote:
> > Hi,
> >
> > is it possible to accept a method without creating instance variable?
> >
> > E.g.
> >
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~
> > Object subclass: #MyObject
> >         slots: {  }
> >         classVariables: {  }
> >         category: 'Category'
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~
> > MyObject>>addValue: aValue
> >         container add: aValue
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > Now normally when I would try to compile the method I would get the
> "Unknown variable 'container'" warning that will force me to either create
> temporary or instance variable; I would like to somehow ignore that,
> because the method will actually never get called.
> >
> > My objective is use this method as a template for code generation, so I
> would then take this method, apply some code transformation and compile it
> into different object.
> >
> > Of course I could do
> >
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > MyObject>>addValueTemplate
> >         ^ 'MyObject>>addValue: aValue
> >                 container add: aValue'
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > But then I would lose code highlighting, which is quite error-prone for
> more complex snippets.
> >
> > If you have a better approach, I am all ears. :)
> >
> > Thanks,
> > Peter
>
> If you are only templating the method and not the whole class, why not
> add it as an instance variable MyObject?
> Or if MyObject is a real domain object with a few template methods,
> maybe put the templates on the class side and add a dummy
> class-instance-variable there.
>
> cheers -ben
>
>

Reply via email to