Binary pattern matching

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Binary pattern matching

Valentin Micic-6
My sincere apology if this has been discussed before…
I vaguely remember that a number of years ago, one was able to write something like this:

some_function( Offset, <<_:Offset/binary-unit:8, Value/binary>> ) -> …

without (Erlang R21.1) compiler complaining with: variable Offset unbound

Was I dreaming? 

Thanks in advance

V/


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Binary pattern matching

Peti Gömöri-2
hi Valentin,

Maybe you remember the case when Offset was bound within the binary?
<<Offset, _:Offset/binary, Value/binary>>

On Sat, Oct 19, 2019 at 8:39 AM Valentin Micic <[hidden email]> wrote:
My sincere apology if this has been discussed before…
I vaguely remember that a number of years ago, one was able to write something like this:

some_function( Offset, <<_:Offset/binary-unit:8, Value/binary>> ) -> …

without (Erlang R21.1) compiler complaining with: variable Offset unbound

Was I dreaming? 

Thanks in advance

V/

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Binary pattern matching

Valentin Micic-6
Indeed, Peti, you are correct… Thanks for the reminder. In fact, this makes a perfect sense :-)

Kind regards

V/

On 19 Oct 2019, at 19:00, Peti Gömöri <[hidden email]> wrote:

hi Valentin,

Maybe you remember the case when Offset was bound within the binary?
<<Offset, _:Offset/binary, Value/binary>>

On Sat, Oct 19, 2019 at 8:39 AM Valentin Micic <[hidden email]> wrote:
My sincere apology if this has been discussed before…
I vaguely remember that a number of years ago, one was able to write something like this:

some_function( Offset, <<_:Offset/binary-unit:8, Value/binary>> ) -> …

without (Erlang R21.1) compiler complaining with: variable Offset unbound

Was I dreaming? 

Thanks in advance

V/

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions