<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 20 Aug 2019, at 18:55, <a href="mailto:empro2@web.de" class="">empro2@web.de</a> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">On Tue, 20 Aug 2019 17:04:26 +0200<br class="">Valentin Micic <<a href="mailto:v@micic.co.za" class="">v@micic.co.za</a>> wrote:<br class=""><br class=""><blockquote type="cite" class="">(tsdb_1_1@macbookv-3)448> is_binary( <<0:1>> ).<br class=""><br class="">false<br class=""></blockquote><br class="">"is elephant?" is encoded in Erlang as: is_bitstring/1<br class=""></div></div></blockquote><div><br class=""></div><div>I see… nevertheless, I prefer <font face="Courier New" class="">is_duck/1</font>, but thank you :-)</div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class="">75> is_bitstring(<<0:1>>).<br class="">is_bitstring(<<0:1>>).<br class="">true<br class=""><br class=""><br class=""><blockquote type="cite" class="">But, if you put two elephants next to each other, you get<br class="">— a duck!<br class=""><br class="">is_binary( <<0:5, 0:3>> ). <br class=""><br class="">true<br class=""></blockquote><br class="">Read "is_binary/1" as<br class="">"is_bitstring/1 and (bitlength_of(Elephants) mod 8 == 0)"<br class=""><br class="">:-)<br class=""></div></div></blockquote><blockquote type="cite" class=""><div class=""><div class=""><br class=""><blockquote type="cite" class="">Given all this, why would anyone find bitstrings useful?<br class=""></blockquote><br class="">That is why the default bitstring is a bytestring or<br class="">octetstring or binary:<br class=""><br class="">98> is_binary(<<"blah">>) and is_binary(<<1, 2, 3>>).<br class="">is_binary(<<"blah">>) and is_binary(<<1, 2, 3>>).<br class="">true<br class=""><br class="">As long as you do not tell the compiler to take bites of<br class="">memory that are no bytes, with that ":", the two of you seem<br class="">to agree there.<br class=""></div></div></blockquote><blockquote type="cite" class=""><div class=""><div class=""><br class="">Might help when extracting flag bits? (or when talking to<br class="">some 9-bit byte PDP ... or was that 11? ... ;-) Anyway I<br class="">would rather deprecate and obsolete away dot notation for<br class="">record elements …<br class=""><br class=""></div></div></blockquote><div><br class=""></div><div>Yes, you could use bit-syntax to extract flags, however, I doubt this will ever be presented to Erlang as a stream of bits (well, at least not nowadays) — unless, of course, Erlang runs on top of the underlying hardware that natively supports 9-bit bytes, of course. And how many of these are available to us today?</div><div><br class=""></div><div>By contrast, the record dot notation is just a syntactic sugar, not a data type. You could chose not to use it (I never do, so no love lost if, or when they remove it). However, a defective usage of record dot syntax may not accidentally introduce a semantic problem, as compiler would definitely help you with identifying a problematic syntax (well, I know, strictly speaking this is not quite true, but go with it, as this is true for record syntax in general, but not to dot notation as such). Unlike situation I’ve described, where I have accidentally introduced a semantic, but not a syntax error (for the reasons Frank explained). </div><div><br class=""></div><div>Oh, please, don’t get me wrong, I like the ability to write <font face="Courier New" class=""><<World:2, Group:2, User:2, <b class="">_:2</b>>> = <<SomeFlags>></font>.</div><div>However, with this construct, you could still extract your flags, but this would not require any new data type (such as bitstring) — e.g. <font face="Courier New" class="">is_binary(<<World:2, Group:2, User:2, <b class="">_:2</b>>> = </font><span style="font-family: "Courier New";" class=""> <<SomeFlags>></span><font face="Courier New" class="">) </font> will merrily report true.</div><div><br class=""></div><div>Contrast this with <font face="Courier New" class=""><<World:2, Group:2, User:2>> = Some6BitBitstring;</font></div><div><br class=""></div><div>which, In order to work, must have <span style="font-family: "Courier New";" class="">Some6BitBitstring</span> set to exactly a six-bit Bitstring, which could only be set from within Erlang runtime, thus fairly artificial construct with respect to the environment, e.g. OS, socket, files, etc.</div><div><br class=""></div><div>Thus, my assertion is that bitstring is a pretty pointless data type. There.</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div class="">/Michael<br class=""><br class="">-- <br class=""><br class="">Normality is merely a question of quantity,<br class="">not of quality.<br class=""><br class=""></div></div></blockquote><div><br class=""></div><div>But, according to Hegelian dialectics, quantity transforms into quality and vice-versa :-)</div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class=""><br class=""><br class=""><br class=""><br class=""><br class=""><br class=""></div></div></blockquote></div><br class=""></body></html>