Comments (4)
eww. that doesn't look right. i'll try check and fix this weekend. sorry,
andrew.
Original comment by [email protected]
on 16 Mar 2012 at 6:36
- Changed state: Accepted
from lepl.
i'm not sure this is the right fix, but i've made String() and related matchers
more string-specific, and they now work as expected.
in general, lepl doesn't assume much about the input (it will "parse" an
iterable of objects, if you can supply the logic), so is completely agnostic
about output type. this change breaks that, but only for those matchers.
an alternative would be to do something based on the type of the input data (ie
use s_join()). but that makes a pile of assumptions about output being the
same as input.
and i feel i am missing something deeper about why an empty string is different
from nothing. what would it mean to match a string against a list of integers,
say? currently it cannot mean anything since that will give an error. but
what would be better than that? an empty list i guess.
anyway, we'll see how this flies. 5.0.2 is available for download/install.
Original comment by [email protected]
on 17 Mar 2012 at 10:18
- Changed state: Fixed
from lepl.
Thanks! I updated to 5.0.2, removed my hack, ran my test suite, and everything
looks good.
I'm not sure I understand the workings of LEPL well enough to comment, but the
fix you applied is what I had in mind as well. It's an issue for any sequence
type that can be empty (so I can see it showing up for Lisp s-expressions as
well), but I don't think there's a need to generalize beyond that.
Cheers, Mark.
Original comment by [email protected]
on 17 Mar 2012 at 11:52
from lepl.
OK, after thinking some more I understand what the "philosophical issue" is
here (I'm writing this down really just for my own internal docs).
String() uses Add() internally, where Add() is defined as applying a "+" to
some data. But that's not a good way to think of reducing sequence data,
because it leaves open what the "zero" value is. We already have a better way
of doing this in functional programming: to reduce a sequence of values to one,
we use fold (or, in python terms, reduce).
And reduce takes two values: zero and operation. Where in this case, operation
is "+" and zero is what is missing.
So the fix was half-way there (I changed the code to use Repeat with a reduce
operator). But a complete fix would introduce a Reduce() matcher that takes a
zero, and String() would allow that to be set.
Which I will do now. In fact, Add() should perhaps be deprecated!
Original comment by [email protected]
on 18 Mar 2012 at 2:46
from lepl.
Related Issues (20)
- Regexp Inverted Ranges Unreliable HOT 1
- LEPL-2.3.2 installed with easy_install gives "ImportError: No module named regexp" error HOT 1
- Error Handling and Tracing HOT 1
- Better graph support HOT 1
- Offside Rule HOT 1
- '*' Operator Fails (Multiple Arguments?) HOT 2
- Cloning loses matchers HOT 2
- Incorrect loop detection HOT 2
- Undo Actions
- lepl.functions.String bug HOT 7
- Regexp / Line Aware Improvements HOT 11
- Join function not in __all__ list HOT 1
- Node should implement __ne__ as well as __eq__ or use == rather than != in __eq__ HOT 1
- Can't print empty lepl.List objects. HOT 3
- antlr grammar for lepl HOT 1
- infinite loop in case of block related grammar HOT 4
- Incorrect example in offside rule documentation HOT 1
- cannot mix strings and tokens HOT 5
- cannot parse from a file HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lepl.