From: Simon Strandgaard Date: 2004-03-31T05:14:24+09:00 Subject: Re: proposal - delayed intropolation in heredoc On Tue, 30 Mar 2004 14:36:46 +0200, Robert Klemme wrote: > "Simon Strandgaard" schrieb im Newsbeitrag > news:pan.2004.03.29.15.49.45.527862@adslhome.dk... >> On Mon, 29 Mar 2004 18:38:20 +0200, Robert Klemme wrote: >> > "Simon Strandgaard" schrieb im Newsbeitrag >> > news:pan.2004.03.29.15.12.59.760809@adslhome.dk... >> >> yet another crazy proposal from me.. read on, am I crazy? >> > >> > Without reading on: yes, you are. But aren't we all? :-)) >> > >> >> I was afraid of that. If you are a genius then its ok to be crazy, >> except that I am not a genius, then its not ok ;-) > > Hey, we can just pretend we're geniusses. If all are crazy anyway then > nobody'll notice. :-) > I prefer being my self, rather than pretending to be somebody else ;-) >> [snip motivation] >> >> >> proposal >> >> ======== >> >> >> >> If we somehow could manipulate the text string before interpolation >> >> occured. For instance by executing code on the HereDoc end tag. >> > >> > In your case manipulation after interpolation would be sufficient. >> > >> >> No, I want to preserve the 'spa ces' in the inline string. >> >> >> The code I have posted is suppose to output >> "pre\n1\n space\n3\npost\n" >> >> Your suggested code outputs: >> "pre\n1\nspace\n3\npost\n" >> >> >> Space isn't preserved.. I think you have misunderstood my proposal ;-) > > Yeah, I overlooked the spaces in the string you insert. But OTOH how > common is this case? > Both in the coverage2html and the ruby2html pieces of code I rely on that spaces is preserved this way. Otherwise indentation will mess up. I could use ' ' but it takes up much space. http://neoneye.dk/coverage/ http://neoneye.dk/syntax.html >> >> Tell me is this a bad idea? >> > >> > I've missed proper indentation often, too. But if you want > indentation >> > why don't you just suggest indentation? The rule could be that as > much >> > white space sitting in front of the terminator is removed from the > lines >> > preceding it, i.e. >> > >> > str = <<-FOO >> > def x >> > puts 'foo' >> > end >> > FOO >> > >> > becomes >> > def x >> > puts 'foo' >> > end >> >> Good idea as long its spaces. I wonder how tabs can be handled properly. >> Should tabs be converted to 8 spaces? Should tabs be sliced? > > I'd just place the general rule that exactly the whitespace that precedes > the terminator is removed from lines inside the here doc, if present. So > if there's a tab in front of the terminator but the lines of the here doc > start with spaces then these are not removed. Don't you think this is > sufficient? > Not sure if I understand your idea on how to deal with tabs. I seems kind of kludgy, sorry. -- Simon Strandgaard