Re: [jinterface] add erlang term parse/match/bind features

Dmitriy Kargapolov <[email protected]> Wed, 31 Dec 2014 11:31:09 -0500
Newsgroups gmane.comp.lang.erlang.patches
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============6149034351388217740==
Content-Type: multipart/alternative;
 boundary="------------030609090609080802010704"

This is a multi-part message in MIME format.
--------------030609090609080802010704
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi Vlad,
Thank you much for your notes.

I agree some names were not good enough, I changed these per your
suggestion.
Old comment removed as well.

As to OtpErangMap class - I was not going to re-implement it initially.
But in order to add match/bind I had to do this. I tried to not add much
new methods, keeping implementation rather "just enough" to work with
maps. You are very welcome to add/change whatever you see reasonable in
separate PR though.

Best Regards and Happy New Year!
- Dmitriy.

git fetch https://github.com/x0id/otp.git jinterface_pattern_matching

https://github.com/x0id/otp/compare/erlang:master...jinterface_pattern_ma=
tching
https://github.com/x0id/otp/compare/erlang:master...jinterface_pattern_ma=
tching.patch

On 12/31/2014 10:27 AM, Vlad Dumitrescu wrote:
> Hi Dmitriy,
>
> Nice implementation! I have something similar that I wanted to submit,
> but I like some of your details better.
>
> I have a few comments, after browsing the code just briefly:
>
> - I would prefer to have the OEMap changes as a separate PR, as it's a
> separate issue and there are more things to address there, like for
> example, OEMap could also implement Map, like OEList implements
> Iterable (and might implement List).=20
> - I don't like the name OEVarrier, it doesn't mean anything. Maybe
> OEMatcher would be better?
> - OEBind might be clearer as OEBinding, as it contains a set of binding=
s?
> - I think there are still some merge issues, like for example
> OEList:299 where the comment is from the old equals method
>
> best regards,
> Vlad
>
>
> On Tue, Dec 30, 2014 at 9:56 PM, Dmitriy Kargapolov
> <[email protected] <mailto:[email protected]>>
> wrote:
>
>     This implements functionality similar to following C functions,
>     which are part of erl_interface application:
>     - ETERM *erl_format(FormatStr, ...);
>     - int erl_match(ETERM *Pattern, ETERM *Term);
>
>     To acheve this new classes introduced:
>     * OtpErlangVar - variable placeholder;
>     * OtpErlangBind - variable values collection;
>     * OtpErlangParser - "erl_format" parser implementation;
>     * OtpErlangPattern - pattern abstraction with match/bind functions;=

>
>     Classes representing composite objects OtpErlangList,
>     OtpErlangTuple, OtpErlangMap and new OtpErlangVar implement
>     interface OtpErlangVarrier defining match and bind functions for
>     these objects.
>
>     Class OtpErlangMap reworked to be based on HashMap instead of two
>     separate lists keeping keys and values. This is close to native
>     semantics of maps and makes easier implementing basic map
>     manipulations.
>
>     It addition to OtpErlangBind custom user's class may be used as
>     receiver of matched variables values. Java reflection is used to
>     prepare variable value setters during the parse stage. Java doc
>     has more details and examples. Test cases implemented.
>
>     git fetch https://github.com/x0id/otp.git jinterface_pattern_matchi=
ng
>
>     Thanks.
>
>
>
>
>
>     _______________________________________________
>     erlang-patches mailing list
>     [email protected] <mailto:[email protected]>
>     http://erlang.org/mailman/listinfo/erlang-patches
>
>


--------------030609090609080802010704
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<html>
  <head>
    <meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Ty=
pe">
  </head>
  <body bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">Hi Vlad,<br>
      Thank you much for your notes.<br>
      <br>
      I agree some names were not good enough, I changed these per your
      suggestion.<br>
      Old comment removed as well.<br>
      <br>
      As to OtpErangMap class - I was not going to re-implement it
      initially. But in order to add match/bind I had to do this. I
      tried to not add much new methods, keeping implementation rather
      "just enough" to work with maps. You are very welcome to
      add/change whatever you see reasonable in separate PR though.<br>
      <br>
      Best Regards and Happy New Year!<br>
      - Dmitriy.<br>
      <br>
      git fetch <a moz-do-not-send=3D"true"
        href=3D"https://github.com/x0id/otp.git" target=3D"_blank">https:=
//github.com/x0id/otp.git</a>
      jinterface_pattern_matching<br>
      <br>
<a class=3D"moz-txt-link-freetext" href=3D"https://github.com/x0id/otp/co=
mpare/erlang:master...jinterface_pattern_matching">https://github.com/x0i=
d/otp/compare/erlang:master...jinterface_pattern_matching</a><br>
<a class=3D"moz-txt-link-freetext" href=3D"https://github.com/x0id/otp/co=
mpare/erlang:master...jinterface_pattern_matching.patch">https://github.c=
om/x0id/otp/compare/erlang:master...jinterface_pattern_matching.patch</a>=
<br>
      <br>
      On 12/31/2014 10:27 AM, Vlad Dumitrescu wrote:<br>
    </div>
    <blockquote
cite=3D"mid:[email protected]=
ail.com"
      type=3D"cite">
      <div dir=3D"ltr">Hi Dmitriy,
        <div><br>
        </div>
        <div>Nice implementation! I have something similar that I wanted
          to submit, but I like some of your details better.</div>
        <div><br>
        </div>
        <div>I have a few comments, after browsing the code just
          briefly:</div>
        <div><br>
        </div>
        <div>- I would prefer to have the OEMap changes as a separate
          PR, as it's a separate issue and there are more things to
          address there, like for example, OEMap could also implement
          Map, like OEList implements Iterable (and might implement
          List).=C2=A0</div>
        <div>- I don't like the name OEVarrier, it doesn't mean
          anything. Maybe OEMatcher would be better?</div>
        <div>- OEBind might be clearer as OEBinding, as it contains a
          set of bindings?</div>
        <div>- I think there are still some merge issues, like for
          example OEList:299 where the comment is from the old equals
          method</div>
        <div><br>
        </div>
        <div>best regards,</div>
        <div>Vlad</div>
        <div><br>
        </div>
      </div>
      <div class=3D"gmail_extra"><br>
        <div class=3D"gmail_quote">On Tue, Dec 30, 2014 at 9:56 PM,
          Dmitriy Kargapolov <span dir=3D"ltr">&lt;<a
              moz-do-not-send=3D"true"
              href=3D"mailto:[email protected]" target=3D"_bla=
nk">[email protected]</a>&gt;</span>
          wrote:<br>
          <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">This
            implements functionality similar to following C functions,
            which are part of erl_interface application:<br>
            - ETERM *erl_format(FormatStr, ...);<br>
            - int erl_match(ETERM *Pattern, ETERM *Term);<br>
            <br>
            To acheve this new classes introduced:<br>
            * OtpErlangVar - variable placeholder;<br>
            * OtpErlangBind - variable values collection;<br>
            * OtpErlangParser - "erl_format" parser implementation;<br>
            * OtpErlangPattern - pattern abstraction with match/bind
            functions;<br>
            <br>
            Classes representing composite objects OtpErlangList,
            OtpErlangTuple, OtpErlangMap and new OtpErlangVar implement
            interface OtpErlangVarrier defining match and bind functions
            for these objects.<br>
            <br>
            Class OtpErlangMap reworked to be based on HashMap instead
            of two separate lists keeping keys and values. This is close
            to native semantics of maps and makes easier implementing
            basic map manipulations.<br>
            <br>
            It addition to OtpErlangBind custom user's class may be used
            as receiver of matched variables values. Java reflection is
            used to prepare variable value setters during the parse
            stage. Java doc has more details and examples. Test cases
            implemented.<br>
            <br>
            git fetch <a moz-do-not-send=3D"true"
              href=3D"https://github.com/x0id/otp.git" target=3D"_blank">=
https://github.com/x0id/otp.git</a>
            jinterface_pattern_matching<br>
            <br>
            Thanks.<br>
            <br>
            <br>
            <br>
            <br>
            <br>
            _______________________________________________<br>
            erlang-patches mailing list<br>
            <a moz-do-not-send=3D"true"
              href=3D"mailto:[email protected]">erlang-patches@er=
lang.org</a><br>
            <a moz-do-not-send=3D"true"
              href=3D"http://erlang.org/mailman/listinfo/erlang-patches"
              target=3D"_blank">http://erlang.org/mailman/listinfo/erlang=
-patches</a><br>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </body>
</html>

--------------030609090609080802010704--

--===============6149034351388217740==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
erlang-patches mailing list
[email protected]
http://erlang.org/mailman/listinfo/erlang-patches

--===============6149034351388217740==--