Re: [rust-dev] Is there a Parsec equivalent in Rust?

2014-06-13 Thread Meredith L. Patterson
That seems a bit excessive. C doesn't have higher-kinded types or monads
either, *and* it's strict, but we cloned Parsec effectively enough. Neither
parser combinators nor PEG/packrat *require* monads, or even lazy
evaluation for that matter; they're just easier to implement that way. You
can even do Iteratees in C. http://code.khjk.org/citer/

Regarding Rick's SWIG question, really I'd rather avoid using SWIG for any
future Hammer bindings, and eventually it'll be eliminated from the
existing ones. But could someone explain what makes generating a set of
Enums more Rust-ish than using a discriminated union?

Don't get me wrong, I love Ragel, but it has its limitations
(character-oriented, not really intended to handle recursion, extra
code-generation step), and Hammer was partially written to address those.

Cheers,
--mlp


On Fri, Jun 13, 2014 at 6:41 AM, Steve Klabnik st...@steveklabnik.com
wrote:

 It's not possible to directly write a Parsec port because we don't
 have HKT and therefore monads. Ragel is probably the best bet for now.
 ___
 Rust-dev mailing list
 Rust-dev@mozilla.org
 https://mail.mozilla.org/listinfo/rust-dev

___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev


Re: [rust-dev] Is there a Parsec equivalent in Rust?

2014-06-12 Thread Meredith L. Patterson
I have been meaning to write Rust bindings for Hammer (
https://github.com/UpstandingHackers/hammer), my C parser-combinator
library which is loosely inspired by Parsec and gratuitously rips off
Scala's packrat parser implementation. There is an issue open for it (
https://github.com/UpstandingHackers/hammer/issues/64), which left off in
December 2013 with the blocking problem that the Rust FFI didn't support
unions yet.

I haven't been following the development of the FFI; are unions supported
yet?

Cheers,
--mlp


On Tue, Jun 10, 2014 at 11:43 PM, Akira Hayakawa hayak...@valinux.co.jp
wrote:

 Hi,

 Haskell's Parsec is really a good tool to parse languages.
 Scala also has the equivalent.

 What about Rust?

 --
 Akira Hayakawa hayak...@valinux.co.jp
 ___
 Rust-dev mailing list
 Rust-dev@mozilla.org
 https://mail.mozilla.org/listinfo/rust-dev

___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev


Re: [rust-dev] Struct members in trait definitions

2013-09-20 Thread Meredith L. Patterson
Hi Andres,

I'm thinking about your question from a structural typing point of view, so
let me see if an analogy from Scala (which has its own take on traits)
helps. Scala is more of an OO language than Rust is, and Scala traits can
extend classes (abstract or not), which is how it's possible for a trait to
incorporate members (what Niko just described as struct inheritance) --
but the trait itself cannot name a new member, only methods, as with Rust.
So in that regard, traits are also an awful lot like Go's interfaces, in
that they describe the interface that a value must be able to satisfy at
compile time. All three languages are structurally typed, but Go has the
fewest bells and whistles in the type system, Scala the most, and Rust
somewhere in the middle (thanks to generics and type bounds). There are
efficiency reasons for that; it's relevant that Scala is a JVM language.

This isn't a particularly concrete answer, but I hope it helps.

Cheers,
--mlp


On Fri, Sep 20, 2013 at 2:18 PM, andres.osin...@gmail.com wrote:

 It would be audacious to propose this as a change; I'm merely trying to
 understand the philosophy behind certain design decisions,

 My personal motivation comes from an interest in seeing how expressive
 Rust can be as a language to model business objects; I think the
 intersection between high-level logic and type classes with low-level
 access, extreme efficiency, and deterministic memory access, is a very
 interesting domain which, thus far, no language manages to handle well, and
 Rust shows immense promise in that.

 Something I really dislike and consider a huge antipattern is the question
 of logical indirection and boilerplate; anything that hinders the
 understanding of the code through unnecessary invocations or synax is a big
 no-no for me (a great example being Java's requirement for type
 declarations everywhere and the disgusting use of accessor methods
 everywhere even when they make no sense).

 Rust is a very lean language and seems to be extremely concise for what
 it's capable of. And the thing is, if a trait has a data dependency rather
 than a behavior (method existence) dependency, then why are we working
 around the data through methods when it just happens to be that what we
 really want is to fetch the data in a struct with no logical
 intermediaries, regardless of whether the compiler turns that into a
 straight memory access?

 The first use case that came to mind was when I was attempting to create a
 business object library that could be used a starting point for forms, data
 persistency, serialization, validation, and the like. I wanted to define,
 for a model, a series of validators that would depend on the struct
 definition; something easy to do with Enums and macros. However when it
 came to validation, i wanted to store certain conditions in a data
 structure, such that all models have a validate() method that would query
 the data needed to perform validation.

 The current trait implementation would require me to needlessly define a
 getter/setter for the validation data structure in order to have a trait.
 In reality, i just want to define the trait as a the existence of a certain
 struct member data definition (a corresponding validators data structure),
 with no limits in how I may want to access of modify such data.

 The beauty of this would be that i would only need to define said member
 and trait in order to get all the features i could ever want out of a
 validation library, and default methods would take care of the rest,
 whereas as it's now, i would have to define the accessors, or use a macro
 so that any model definition would come with an automatic accessor
 definition. This is not ideal if I have a system with several hundred
 models, which may be trivial in their definition but require a useless
 method definition for each of them.

 And while I think it's great that a macro is capable of that, it seems to
 me that as a language feature it would be substantially more useful.

 Like I said before, I'm just toying around; I have little frame of
 reference as to whether there are hidden downsides to such a feature. I
 just wanted to know what the community thinks about this.

 Thanks
 Enviado desde mi BlackBerry de Movistar (http://www.movistar.com.ar)
 --
 *From: * Felix S. Klock II pnkfe...@mozilla.com
 *Date: *Fri, 20 Sep 2013 13:41:02 +0200
 *To: *Andres Osinskiandres.osin...@gmail.com
 *Cc: *rust-dev@mozilla.orgrust-dev@mozilla.org
 *Subject: *Re: [rust-dev] Struct members in trait definitions

 Andres (cc'ing rust-dev)-

 An initial question, since I'm not clear on one thing:

 What is your goal in proposing this change?

 That is, is your primary concern that you dislike writing either method
 invocations or method definitions?  Or are you concerned about the ability
 of the compiler to optimize the generated code if one uses methods instead
 of struct fields?

 

 Justifications for why traits