metaeducation / ren-c

Library for embedding a Rebol interpreter into C codebases
GNU Lesser General Public License v3.0
128 stars 27 forks source link

Parse not returning matched position #1102

Closed rgchris closed 3 years ago

rgchris commented 3 years ago

Expected behaviour:

‌>> parse [a b c] [some word! mk:]
== []

Actual behaviour:

‌>> parse [a b c] [some word! mk:]
== [a b c]

Tested: Ren Garden, Version: 2.102.0.16.1, Build: 24-Nov-2020/22:56:39+0:00

hostilefork commented 3 years ago

Weighing the pros and cons made me believe that defaulting to requiring reaching the END--the historical behavior--was likely the best default. But that requesting how far you progressed would implicitly signal that you need not reach the end, and return that progress amount.

https://forum.rebol.info/t/the-parse-of-progress/1349

The main thing to decide is a syntax for saying you're only interested in the progress, which is something that hasn't been firmed up for multi-returns yet.

hostilefork commented 3 years ago

Note also that multi-returns can be interacted with via passing words conventionally:

>> parse/progress "abc" ["ab"] 'pos
== "abc"

>> pos
== "c"