[Aeditor-talk] Regexp assertions

Simon Strandgaard neoneye at adslhome.dk
Sat Dec 13 14:18:03 EST 2003


On Sat, 2003-12-13 at 13:10, Mark wrote:
> On Saturday 13 Dec 2003 10:38 am, Simon Strandgaard wrote:
> > On Fri, 2003-12-12 at 21:46, Mark wrote:

> > > I have a couple of questions
> > >
> > > I want to add some new classes for code assertions and closures,
> > >
> > > CodeBlock
> > > 	CodeAssertion
> > > 	Closure
> >
> > From my brief understanding of perl6, the only thing which are the
> > difference on {closure} and <codeassertion>, are that codeassert ignores
> > the result ?   Is that correct?
> >
> Actually closures ignore the result.

OK



> > If this is the case, then I would join the 2 classes. Perhaps call the
> > class 'InlineCode'... and have a boolean which indicates weather the
> > result should be ignored or not.
> >
> 
> One problem is after rereading the docs I've found a third type of code block, 
> created using <{...}>. this executes the code and adds the result to the 
> regexp.

ok


> The types are
> Closure 			{...}		Fails the match if the code raises an exception
> Code assertion	<(...)>	Fails the match if the code returns false
> Regexp code		<{...}>	Inserts the return value into the regexp
> 
> There are two ways to handle these
> 1: use a single class, storing the type of code block as a flag within the 
> class
> 2: use a class for each type of code block
> 
> Personally I'd prefer to go the second route. Most of the code would be within 
> the base class with each subclass overriding the call method to do the right 
> thing.

problem with (2) are that you will repeat code _many_ times. 
You will have to add 3 classes to AbstractSyntax module,
extend every visitors with 3 #visit_xx methods.

(1) is easiest to maintain and keep the big overview, thats what 
OO are all about.   I like (1).


--
Simon Strandgaard




More information about the Aeditor-talk mailing list