[Spirit2X] post-skipping phrase_parse?

classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|

[Spirit2X] post-skipping phrase_parse?

Francois Barel
Hi list,

Recently I looked at examples which are missing a final post-skip,
trying to add it. Take for example mini_xml2:
- I added ">> -eoi" in phrase_parse after the grammar,
- which broke attribute handling (since the attribute given to
phrase_parse is a fusion sequence, and the parser which wasn't a
sequence before has now become one),
- which means the attribute now needs to be wrapped in a
fusion::vector1 for things to work again.
This feels much more complicated than it should be...


In my own experience, wanting a final post-skip is the rule, and not
wanting it is really the exception. And judging by the number of times
this subject has been raised on the ML (in Spirit1 when the final
post-skip got removed, and now in Spirit2) I think many people feel
the same, and are surprised that there is no final post-skip when they
use a skipper.

I agree that there must be a way to prevent the final post-skip, but
there should also be an easy way to have it -- and I don't think
having to add ">> -eoi", especially with potential impact on
attributes, qualifies as easy (and explicit) enough.
What do you think about adding a new bool argument -- either template
or run-time -- to phrase_parse (and phrase_match too I guess)
indicating whether to do the post-skipping? (or a new function
completely?)

Thanks,
François

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] post-skipping phrase_parse?

CARL BARRON-3

On Mar 2, 2009, at 1:44 AM, Francois Barel wrote:

> Hi list,
>
> Recently I looked at examples which are missing a final post-skip,
> trying to add it. Take for example mini_xml2:
> - I added ">> -eoi" in phrase_parse after the grammar,
> - which broke attribute handling (since the attribute given to
> phrase_parse is a fusion sequence, and the parser which wasn't a
> sequence before has now become one),
> - which means the attribute now needs to be wrapped in a
> fusion::vector1 for things to work again.
> This feels much more complicated than it should be...
>
>
> In my own experience, wanting a final post-skip is the rule, and not
> wanting it is really the exception. And judging by the number of times
> this subject has been raised on the ML (in Spirit1 when the final
> post-skip got removed, and now in Spirit2) I think many people feel
> the same, and are surprised that there is no final post-skip when they
> use a skipper.
>
> I agree that there must be a way to prevent the final post-skip, but
> there should also be an easy way to have it -- and I don't think
> having to add ">> -eoi", especially with potential impact on
> attributes, qualifies as easy (and explicit) enough.
> What do you think about adding a new bool argument -- either template
> or run-time -- to phrase_parse (and phrase_match too I guess)
> indicating whether to do the post-skipping? (or a new function
> completely?)


  wwll  h = g >> -eoi means

        g >> eoi  | g   which means the bool return only guarentees that it  
matches a g not that
the rest of the input was skippable.  So if g >> -eoi returned  
something different from a fusion sequence I'd be disappointed as it  
makes -eoi a no op.

the correct way is  g >> eoi  this means g followed by only skippable  
chars if any are present.
eoi  essentially pre-skips and then tests the iterator pair for an  
empty sequence, [first == last].  If there is no data left for eoi to  
parse it returns true.

I see no need for added complexity as g >> eoi should work just fine.



------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] post-skipping phrase_parse?

Joel de Guzman-2
In reply to this post by Francois Barel
Francois Barel wrote:

> Hi list,
>
> Recently I looked at examples which are missing a final post-skip,
> trying to add it. Take for example mini_xml2:
> - I added ">> -eoi" in phrase_parse after the grammar,
> - which broke attribute handling (since the attribute given to
> phrase_parse is a fusion sequence, and the parser which wasn't a
> sequence before has now become one),
> - which means the attribute now needs to be wrapped in a
> fusion::vector1 for things to work again.
> This feels much more complicated than it should be...
>
>
> In my own experience, wanting a final post-skip is the rule, and not
> wanting it is really the exception. And judging by the number of times
> this subject has been raised on the ML (in Spirit1 when the final
> post-skip got removed, and now in Spirit2) I think many people feel
> the same, and are surprised that there is no final post-skip when they
> use a skipper.
>
> I agree that there must be a way to prevent the final post-skip, but
> there should also be an easy way to have it -- and I don't think
> having to add ">> -eoi", especially with potential impact on
> attributes, qualifies as easy (and explicit) enough.
> What do you think about adding a new bool argument -- either template
> or run-time -- to phrase_parse (and phrase_match too I guess)
> indicating whether to do the post-skipping? (or a new function
> completely?)

I agree 100%. Are there any objections? Francois, if there are
no objections, can you take care of this? I like your solution.
I agree that the default should allow (one and only one) final
post-skip.

Cheers,
--
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] post-skipping phrase_parse?

Francois Barel
In reply to this post by CARL BARRON-3
Carl Barron wrote:
>  wwll  h = g >> -eoi means
>
>        g >> eoi  | g   which means the bool return only guarentees that it
> matches a g not that
> the rest of the input was skippable.  So if g >> -eoi returned
> something different from a fusion sequence I'd be disappointed as it
> makes -eoi a no op.

Both work as bit differently:
- "g >> -eoi" will indeed return true as long as g matches, even if
the rest is not skippable -- which means you have to check whether
"first == last" after phrase_parse to know if you had a full match
(that's what the examples do),
- "g >> eoi" will fail and directly return false if g matches but the
rest is not skippable,
so I guess it's a matter of personal preference.


> the correct way is  g >> eoi  this means g followed by only skippable
> chars if any are present.
> eoi  essentially pre-skips and then tests the iterator pair for an
> empty sequence, [first == last].  If there is no data left for eoi to
> parse it returns true.
>
> I see no need for added complexity as g >> eoi should work just fine.

But my point is that:
- if parser "g" has expected attribute type "attr" where "attr" is a
fusion sequence,
- phrase_parse(..., g, instance_of_attr) works,
- phrase_parse(..., g >> eoi, instance_of_attr) doesn't work, because
then Spirit attempts to assign the attribute of "g" to
"fusion::at_c<0>(instance_of_attr)" instead of the whole
"instance_of_attr".

IOW, adding ">> eoi" is not transparent: it has an impact on attribute
types -- whereas I think we agree that choosing to post-skip shouldn't
have any.

Regards,
François

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] post-skipping phrase_parse?

Francois Barel
In reply to this post by Joel de Guzman-2
Joel de Guzman wrote:

> Francois Barel wrote:
>> I agree that there must be a way to prevent the final post-skip, but
>> there should also be an easy way to have it -- and I don't think
>> having to add ">> -eoi", especially with potential impact on
>> attributes, qualifies as easy (and explicit) enough.
>> What do you think about adding a new bool argument -- either template
>> or run-time -- to phrase_parse (and phrase_match too I guess)
>> indicating whether to do the post-skipping? (or a new function
>> completely?)
>
> I agree 100%. Are there any objections? Francois, if there are
> no objections, can you take care of this? I like your solution.
> I agree that the default should allow (one and only one) final
> post-skip.

Sure. We just have to agree on the interface. I was thinking of adding
the bool argument at the end like this:

    template <typename Iterator, typename Expr, typename Skipper>
    bool phrase_parse(Iterator& first, Iterator last
      , Expr const& expr
      , Skipper const& skipper, bool postskip = true);

    template <typename Iterator, typename Expr, typename Attr, typename Skipper>
    bool phrase_parse(Iterator& first, Iterator last
      , Expr const& expr, Attr& attr
      , Skipper const& skipper, bool postskip = true);

I'd like the default value to be "true" -- is that what you were
suggesting above when saying "the default should allow ... final
post-skip"? I just realized Spirit2 currently does that final
post-skip, I wasn't aware of that -- so that won't break compatibility
with Spirit2.

Any objections?

Regards,
François

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] post-skipping phrase_parse?

Joel de Guzman-2
In reply to this post by CARL BARRON-3
Carl Barron wrote:

> On Mar 2, 2009, at 1:44 AM, Francois Barel wrote:
>
>> Hi list,
>>
>> Recently I looked at examples which are missing a final post-skip,
>> trying to add it. Take for example mini_xml2:
>> - I added ">> -eoi" in phrase_parse after the grammar,
>> - which broke attribute handling (since the attribute given to
>> phrase_parse is a fusion sequence, and the parser which wasn't a
>> sequence before has now become one),
>> - which means the attribute now needs to be wrapped in a
>> fusion::vector1 for things to work again.
>> This feels much more complicated than it should be...
>>
>>
>> In my own experience, wanting a final post-skip is the rule, and not
>> wanting it is really the exception. And judging by the number of times
>> this subject has been raised on the ML (in Spirit1 when the final
>> post-skip got removed, and now in Spirit2) I think many people feel
>> the same, and are surprised that there is no final post-skip when they
>> use a skipper.
>>
>> I agree that there must be a way to prevent the final post-skip, but
>> there should also be an easy way to have it -- and I don't think
>> having to add ">> -eoi", especially with potential impact on
>> attributes, qualifies as easy (and explicit) enough.
>> What do you think about adding a new bool argument -- either template
>> or run-time -- to phrase_parse (and phrase_match too I guess)
>> indicating whether to do the post-skipping? (or a new function
>> completely?)
>
>
>   wwll  h = g >> -eoi means
>
> g >> eoi  | g   which means the bool return only guarentees that it  
> matches a g not that
> the rest of the input was skippable.  So if g >> -eoi returned  
> something different from a fusion sequence I'd be disappointed as it  
> makes -eoi a no op.
>
> the correct way is  g >> eoi  this means g followed by only skippable  
> chars if any are present.
> eoi  essentially pre-skips and then tests the iterator pair for an  
> empty sequence, [first == last].  If there is no data left for eoi to  
> parse it returns true.
>
> I see no need for added complexity as g >> eoi should work just fine.

Good point.

Cheers,
--
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] post-skipping phrase_parse?

Joel de Guzman-2
In reply to this post by Francois Barel
Francois Barel wrote:

> But my point is that:
> - if parser "g" has expected attribute type "attr" where "attr" is a
> fusion sequence,
> - phrase_parse(..., g, instance_of_attr) works,
> - phrase_parse(..., g >> eoi, instance_of_attr) doesn't work, because
> then Spirit attempts to assign the attribute of "g" to
> "fusion::at_c<0>(instance_of_attr)" instead of the whole
> "instance_of_attr".
>
> IOW, adding ">> eoi" is not transparent: it has an impact on attribute
> types -- whereas I think we agree that choosing to post-skip shouldn't
> have any.

Yes. I understand that. That is why I am in agreement with Francois.
Also, this no-post-skipping behavior is becoming to be a cause of
confusion considering the number of times it has been brought up
in the Spirit list. It is simply un-intuitive. I, for one, do not
want to have to answer another of this kind of questions in the
list. To be honest, this is one of the changes we did that I regret.
If we had done sonething like what Francois is proposing now, we
would have been better of. What we did was a big fat breaking change
that needlessly broke lots of applications.

Regards,
--
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] post-skipping phrase_parse?

Joel de Guzman-2
In reply to this post by Francois Barel
Francois Barel wrote:

> Joel de Guzman wrote:
>> Francois Barel wrote:
>>> I agree that there must be a way to prevent the final post-skip, but
>>> there should also be an easy way to have it -- and I don't think
>>> having to add ">> -eoi", especially with potential impact on
>>> attributes, qualifies as easy (and explicit) enough.
>>> What do you think about adding a new bool argument -- either template
>>> or run-time -- to phrase_parse (and phrase_match too I guess)
>>> indicating whether to do the post-skipping? (or a new function
>>> completely?)
>> I agree 100%. Are there any objections? Francois, if there are
>> no objections, can you take care of this? I like your solution.
>> I agree that the default should allow (one and only one) final
>> post-skip.
>
> Sure. We just have to agree on the interface. I was thinking of adding
> the bool argument at the end like this:
>
>     template <typename Iterator, typename Expr, typename Skipper>
>     bool phrase_parse(Iterator& first, Iterator last
>       , Expr const& expr
>       , Skipper const& skipper, bool postskip = true);
>
>     template <typename Iterator, typename Expr, typename Attr, typename Skipper>
>     bool phrase_parse(Iterator& first, Iterator last
>       , Expr const& expr, Attr& attr
>       , Skipper const& skipper, bool postskip = true);
>
> I'd like the default value to be "true" -- is that what you were
> suggesting above when saying "the default should allow ... final
> post-skip"? I just realized Spirit2 currently does that final
> post-skip, I wasn't aware of that -- so that won't break compatibility
> with Spirit2.
>
> Any objections?

No objections here. Looks good to me.

Regards,
--
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] post-skipping phrase_parse?

Hartmut Kaiser
In reply to this post by Francois Barel
> Joel de Guzman wrote:
> > Francois Barel wrote:
> >> I agree that there must be a way to prevent the final post-skip, but
> >> there should also be an easy way to have it -- and I don't think
> >> having to add ">> -eoi", especially with potential impact on
> >> attributes, qualifies as easy (and explicit) enough.
> >> What do you think about adding a new bool argument -- either
> template
> >> or run-time -- to phrase_parse (and phrase_match too I guess)
> >> indicating whether to do the post-skipping? (or a new function
> >> completely?)
> >
> > I agree 100%. Are there any objections? Francois, if there are
> > no objections, can you take care of this? I like your solution.
> > I agree that the default should allow (one and only one) final
> > post-skip.
>
> Sure. We just have to agree on the interface. I was thinking of adding
> the bool argument at the end like this:
>
>     template <typename Iterator, typename Expr, typename Skipper>
>     bool phrase_parse(Iterator& first, Iterator last
>       , Expr const& expr
>       , Skipper const& skipper, bool postskip = true);
>
>     template <typename Iterator, typename Expr, typename Attr, typename
> Skipper>
>     bool phrase_parse(Iterator& first, Iterator last
>       , Expr const& expr, Attr& attr
>       , Skipper const& skipper, bool postskip = true);
>
> I'd like the default value to be "true" -- is that what you were
> suggesting above when saying "the default should allow ... final
> post-skip"? I just realized Spirit2 currently does that final
> post-skip, I wasn't aware of that -- so that won't break compatibility
> with Spirit2.
>
> Any objections?

No objections. But a question: Currently Karma doesn't do any explicit
pre-delimiting (remember, Karma does everything inside out if compared to
Qi, so the usual thing is to post-delimit). Should we add something similar
to generate_delimited()/format_delimited() to allow for an additional
delimiter in front of the generated output?

Regards Hartmut




------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] post-skipping phrase_parse?

Francois Barel
In reply to this post by Joel de Guzman-2
Joel de Guzman wrote:
> No objections here. Looks good to me.

Done, committed to svn as r1088.

Cheers,
François

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] post-skipping phrase_parse?

Francois Barel
In reply to this post by Hartmut Kaiser
Hartmut Kaiser wrote:
> No objections. But a question: Currently Karma doesn't do any explicit
> pre-delimiting (remember, Karma does everything inside out if compared to
> Qi, so the usual thing is to post-delimit). Should we add something similar
> to generate_delimited()/format_delimited() to allow for an additional
> delimiter in front of the generated output?

I'll gladly do the same for Karma, it sounds useful too to control
pre-delimiting.

However I don't have any experience with it, so I'm not sure if the
default should be true? Although I'd like to say yes for consistency
with Qi, I don't really know what makes more sense as a default.
I can imagine some use cases where I'd want pre-delimiting, as well as
some others where I wouldn't... But overall I think that most of the
time, I wouldn't want it.

Regards,
François

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] post-skipping phrase_parse?

CARL BARRON-3
In reply to this post by Francois Barel

On Mar 2, 2009, at 6:02 PM, Francois Barel wrote:

> Joel de Guzman wrote:
>> No objections here. Looks good to me.
>
> Done, committed to svn as r1088.
>
> Cheers,
> François
    Looks ok.,  just wondering about efficiency.  Seems like overloads  
might be a better idea.

   pre r1088 interface  = always post-skip

   pre r1088 interface with added mpl::false_ parameter  means never  
post-skip.

prehaps  pre 1088 interface with added bool not defaulted allows a  
runtime test of whether
to post-skip or not.

am I missing something , since the same rules to avoid ambiguity will  
work with mpl;:false_
and bool.  if one really wants to turn post-skipping on/off at runtime.



------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] post-skipping phrase_parse?

OvermindDL1
On Mon, Mar 2, 2009 at 8:15 PM, Carl Barron <[hidden email]> wrote:

>
> On Mar 2, 2009, at 6:02 PM, Francois Barel wrote:
>
>> Joel de Guzman wrote:
>>> No objections here. Looks good to me.
>>
>> Done, committed to svn as r1088.
>>
>> Cheers,
>> François
>    Looks ok.,  just wondering about efficiency.  Seems like overloads
> might be a better idea.
>
>   pre r1088 interface  = always post-skip
>
>   pre r1088 interface with added mpl::false_ parameter  means never
> post-skip.
>
> prehaps  pre 1088 interface with added bool not defaulted allows a
> runtime test of whether
> to post-skip or not.
>
> am I missing something , since the same rules to avoid ambiguity will
> work with mpl;:false_
> and bool.  if one really wants to turn post-skipping on/off at runtime.

For note, I am one of those that needs post-skipping off, would prefer
not to have any kind of speed hit because of this change either, thus
the mpl overloading version sounds best to me.  :)

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] post-skipping phrase_parse?

Francois Barel
In reply to this post by CARL BARRON-3
Carl Barron wrote:

>    Looks ok.,  just wondering about efficiency.  Seems like overloads
> might be a better idea.
>
>   pre r1088 interface  = always post-skip
>
>   pre r1088 interface with added mpl::false_ parameter  means never
> post-skip.
>
> prehaps  pre 1088 interface with added bool not defaulted allows a
> runtime test of whether
> to post-skip or not.
>
> am I missing something , since the same rules to avoid ambiguity will
> work with mpl;:false_
> and bool.  if one really wants to turn post-skipping on/off at runtime.

I wondered about it for a bit and yes, ideally I'd have preferred a
version where the flag was a compile-time constant (either a bool
non-type template parameter, or a mpl::false_ / mpl::true_ as you said
-- or a new overload altogether), but I thought it would make the
thing much more akward to use for no good reason -- I really don't
think performance is an issue here because:
- performance loss should be minimal either way (just one or two
additional tests)
- phrase_parse is an entry point, it's only called once per parse so I
don't think it matters that much
- and most of all if the flag is constant (which I think it will be
>99.9% of the time) I'm sure the optimizer will easily drop the test
when inlining (and drop the new skip_over call if the flag is false),
generating the exact same code as you would have obtained from the two
hand-written overloads -- especially since phrase_parse is the entry
point called directly from user-code (it's not like it's deeply
nested, which admittedly could make the optimizer's job harder)

Just to be sure, I'll run performance tests to see if there is a
noticeable change (between old version with no post-skipping, and new
version with flag set to false to keep post-skipping disabled), and
I'll report back here.

Regards,
François

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] post-skipping phrase_parse?

Francois Barel
Francois Barel wrote:
> Just to be sure, I'll run performance tests to see if there is a
> noticeable change (between old version with no post-skipping, and new
> version with flag set to false to keep post-skipping disabled), and
> I'll report back here.

OK, here are the results of some tests (on MSVC9 RTM). Numbers are
times in ms it took to run a lot of
- phrase_parse(..., space) for r1087,
- phrase_parse(..., space, false) for r1088 (same behavior with new interface),
I took 10 samples for each.

r1087: 22344 22344 22328 22328 22359 22344 22312 22328 22406 22344
(avg: 22343.7)
r1088: 22313 22313 22297 22266 22282 22281 22297 22296 22297 22297
(avg: 22293.9)

These seem to show a very slight advantage to the new code (0.22 %),
but I believe it's within the margin of measurements error --
especially since as I expected, the compiler generated strictly
equivalent code in both cases.
IOW the added code is completely optimized out in case the post_skip
flag is known to be false at compile-time, so I see nothing to worry
about performance-wise.

Regards,
François

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] post-skipping phrase_parse?

Joel de Guzman-2
Francois Barel wrote:

> Francois Barel wrote:
>> Just to be sure, I'll run performance tests to see if there is a
>> noticeable change (between old version with no post-skipping, and new
>> version with flag set to false to keep post-skipping disabled), and
>> I'll report back here.
>
> OK, here are the results of some tests (on MSVC9 RTM). Numbers are
> times in ms it took to run a lot of
> - phrase_parse(..., space) for r1087,
> - phrase_parse(..., space, false) for r1088 (same behavior with new interface),
> I took 10 samples for each.
>
> r1087: 22344 22344 22328 22328 22359 22344 22312 22328 22406 22344
> (avg: 22343.7)
> r1088: 22313 22313 22297 22266 22282 22281 22297 22296 22297 22297
> (avg: 22293.9)
>
> These seem to show a very slight advantage to the new code (0.22 %),
> but I believe it's within the margin of measurements error --
> especially since as I expected, the compiler generated strictly
> equivalent code in both cases.
> IOW the added code is completely optimized out in case the post_skip
> flag is known to be false at compile-time, so I see nothing to worry
> about performance-wise.

As I expected ;-)

Regards,
--
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] post-skipping phrase_parse?

Hartmut Kaiser
In reply to this post by Francois Barel

> > No objections. But a question: Currently Karma doesn't do any
> explicit
> > pre-delimiting (remember, Karma does everything inside out if
> compared to
> > Qi, so the usual thing is to post-delimit). Should we add something
> similar
> > to generate_delimited()/format_delimited() to allow for an additional
> > delimiter in front of the generated output?
>
> I'll gladly do the same for Karma, it sounds useful too to control
> pre-delimiting.
>
> However I don't have any experience with it, so I'm not sure if the
> default should be true? Although I'd like to say yes for consistency
> with Qi, I don't really know what makes more sense as a default.
> I can imagine some use cases where I'd want pre-delimiting, as well as
> some others where I wouldn't... But overall I think that most of the
> time, I wouldn't want it.

I think the default should be not to pre-delimit. I would appreciate if you
were adding it.

Thanks!
Regards Hartmut



------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] post-skipping phrase_parse?

Francois Barel
Hartmut Kaiser wrote:
> I think the default should be not to pre-delimit. I would appreciate if you
> were adding it.

Done in svn r1092.

Regards,
François

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] post-skipping phrase_parse?

Hartmut Kaiser
Thanks!
Regards Hartmut

> -----Original Message-----
> From: Francois Barel [mailto:[hidden email]]
> Sent: Thursday, March 05, 2009 4:43 PM
> To: [hidden email]; Spirit Development
> Subject: Re: [Spirit-devel] [Spirit2X] post-skipping phrase_parse?
>
> Hartmut Kaiser wrote:
> > I think the default should be not to pre-delimit. I would appreciate
> if you
> > were adding it.
>
> Done in svn r1092.
>
> Regards,
> François


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel