Giter Site home page Giter Site logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 18, 2024
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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.