Andrew Miller writes: Ok. Now another question. Have you added some kind of early-out construct to traversals? Let's say I was searching for something and I've found it. I now want to end the traversal. No we don't have a structure-shy construct to get out from a deep traversal. It is something we have been thinking about. Your implementation will give some clues on how to approach this. -- Karl From dougo@ccs.neu.edu Tue Jun 2 18:51:37 1998 From: Doug Orleans To: Karl Lieberherr Cc: amiller@xis.xerox.com Subject: Re: Demjava Karl Lieberherr writes: > Something like this should work: > > > String get_filename() > > to FileName > > { > (@ String s; @) > > before FileName (@ s = host.get_string(); @) > > return String (@ s @) > > } This will work, although you can just say return (@ s @) since the visitor is defined inline, so the return type is known (from the method signature). Or you could just do: String get_filename() to FileName { before FileName (@ return_val = host.get_string(); @) } --Doug From amiller@xis.xerox.com Tue Jun 2 17:47:47 1998 From: amiller@xis.xerox.com (Andrew Miller) Subject: Re[2]: Demjava To: Karl Lieberherr Ok. Now another question. Have you added some kind of early-out construct to traversals? Let's say I was searching for something and I've found it. I now want to end the traversal. If not, I'll implement it myself using exceptions. Andrew ______________________________ Reply Separator _________________________________ Subject: Re: Demjava Author: Karl Lieberherr at intergate Date: 6/2/98 2:34 PM Something like this should work: > String get_filename() > to FileName > { (@ String s; @) > before FileName (@ s = host.get_string(); @) > return String (@ s @) > } > > >From amiller@xis.xerox.com Tue Jun 2 17:24:03 1998 >From: amiller@xis.xerox.com (Andrew Miller) >Subject: Demjava >To: Karl Lieberherr > > Prof Lieberherr- > > I am a bit confused by the definition for inlined traversal > definitions. Here's a working example: > > String get_filename(String s) > to FileName > { > before FileName (@ s = host.get_string(); @) > return String (@ s @) > } > > > I don't need the arg "s" but it seems that I need to store "s" when I > get to FileName. Is this correct? I would like to just return > host.get_string() in the "before FileName" section. > > Can I declare "s" as a local variable so that the caller of > get_filename() doesn't have to provide the string storage? > > Andrew >