[M3devel] I know, I know...
Mika Nystrom
mika at async.caltech.edu
Fri Aug 24 01:07:44 CEST 2012
Well .M3WEB isn't defined in the Green Book....
Actually I take back what I said before. If I was doing what you
are describing from scratch, I'd write a Scheme program that takes an
S-expression according to certain rules and generates both an interface
defining a RECORD type Interface.T and packing/unpacking code in Modula-3
but following Jay's outline. Then I'd write a template file that allows
me to specify said Scheme file in m3makefile. The advantage of this
approach is that it doesn't rely on any compiler internals or special
output files. And it's at least as powerful as any pragmas you might
want to add. Plus easier to implement...
Below is a very partial example of something similar... it defines a SQL
database together with Modula-3 code for accessing the tables in that
database (in very multithreaded and pipelined ways). I only define two
tables, you can imagine what the rest looks like. It's for a real-time
financial trading application, if you were wondering. The Scheme is
253 lines and results in 8,828 lines of Modula-3 code and 361 lines
of SQL. The code generator is only 1,197 lines of Scheme and that is
including liberal documentation. (The system is similar to "Hibernate"
but I suspect with more emphasis on certain kinds of performance that
we cared very much about in the trading application, e.g., latency of
piping data through the database.) The whole thing is added to the
program by adding a single line to m3makefile.
Mika
(define aux-mm-ordr-ctrl
(make-table "aux_mm_ordr_ctrl" 'client
(make-field "symbol" 'varchar 'not-null)
(make-index (list "symbol"))
(make-field "type" 'varchar 'not-null)
(make-field "expiry" 'varchar 'not-null)
(make-field "exchange" 'varchar 'not-null)
(make-field "currency" 'varchar 'not-null)
(make-field "action" 'varchar 'not-null)
(make-field "quantity" 'double-precision 'not-null)
(make-field "order_type" 'varchar 'not-null)
(make-field "benchmark_price" 'double-precision)
(make-field "time_allowance" 'double-precision)
(make-field "model_name" 'varchar)
(make-index (list "model_name"))
(make-field "id" 'integer)
))
(define clean
(make-table "clean" 'server
(make-field "tabl" 'varchar 'not-null)
(make-field "rowid" 'integer 'not-null)
(make-field "client" 'varchar 'not-null)
(make-index (list "client"))
(make-index (list "tabl"))
(make-index (list "tabl" "rowid"))
(make-index (list "client" "tabl"))))
(define gcoms
(make-database "gcoms"
clean
code model instrument strategy model-data
model-code
ordr ordr_status
output eror
fill
aux-instrument
aux-ordr
aux-ordr-params
aux-market-segment
aux-last-prices
aux-mm-ordr-ctrl
aux-mm-associations
))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(write-database-sql gcoms)
(write-database-m3 gcoms)
=?utf-8?Q?Dragi=C5=A1a_Duri=C4=87?= writes:
>
>--Apple-Mail=_6458BB99-E0EF-4A10-A66A-491737830F8E
>Content-Type: multipart/alternative;
> boundary="Apple-Mail=_97F57BF6-5A6D-479B-8575-88C17BAE93B4"
>
>
>--Apple-Mail=_97F57BF6-5A6D-479B-8575-88C17BAE93B4
>Content-Transfer-Encoding: quoted-printable
>Content-Type: text/plain;
> charset=utf-8
>
>I have RTInfo module we developed years ago to parse .M3WEB. Good =
>enough? :) But, not a solution, it is easier to write as I wrote in =
>example I used to illustrate problem.
>
>GCC not obeying packing instructions is like=E2=80=A6 GCC not working in =
>lot of cases. For some reason, I don't believe in it.
>
>Hint, gm2 is GCC based compiler. And supports very precise =
>packing/aligning rules.
>
>--
>Divided by a common language
>
>Dragi=C5=A1a Duri=C4=87
>dragisha at m3w.org
>
>
>
>
>On Aug 23, 2012, at 9:51 PM, Mika Nystrom wrote:
>
>>=20
>> Well I don't think Jay said that bytes couldn't be unpacked in =
>Modula-3
>> (you can just use Word for that).
>>=20
>> But I think the point was that a compiler back-end might not =
>necessarily
>> obey your packing instructions?
>>=20
>> Here's what I think you should do... it would be super useful, both to
>> you and other people in the future. And completely independent of
>> compilers.
>>=20
>> Write a something-or-other that uses m3tk to read your RECORD type
>> spec, plus pragmas of your own choice (or comments, or auxiliary data
>> from somewhere) and then generates code using Word.T that can process
>> byte streams and return the RECORD you declared, in portable Modula-3.
>> I doubt it's very difficult. m3tk is cool!
>>=20
>> Mika
>>=20
>> =3D?utf-8?Q?Dragi=3DC5=3DA1a_Duri=3DC4=3D87?=3D writes:
>>>=20
>>> --Apple-Mail=3D_8871A9FB-3130-4B36-8524-F6549A5CEC9E
>>> Content-Type: multipart/alternative;
>>> boundary=3D"Apple-Mail=3D_2314A877-555E-4BDE-8112-C875A2AE5122"
>>>=20
>>>=20
>>> --Apple-Mail=3D_2314A877-555E-4BDE-8112-C875A2AE5122
>>> Content-Transfer-Encoding: quoted-printable
>>> Content-Type: text/plain;
>>> charset=3Dwindows-1250
>>>=20
>>> I have a friend, working for large software company and he just =
>recently =3D
>>> ported some message router from SPARC to Linux/Intel=3D85 Lots of =
>"network =3D
>>> order" data, same as with my current projects. Network, communication =
>in =3D
>>> general, network order is everywhere.
>>>=20
>>> Insisting on some god-given data ordering is a bit=3D85 What is nice =
>word =3D
>>> here? :) Outlandish? Outimeish?
>>>=20
>>> This is not first time I started discussion like this here. Every =
>single =3D
>>> time Jay explains to me how Modula-3 cannot handle it. I am handling =
>it, =3D
>>> as I have shown in my example, with Modula-3 code. With a bit of =
>effort =3D
>>> I can make it almost-transparent (subfolder/platform) over various =3D
>>> platforms. Of course, as I am developing a full product (not software =
>to =3D
>>> be run on arbitrary platform) I don't have to worry about too many =3D
>>> platforms. One is enough here, but I still think Modula-3 can =
>benefit, =3D
>>> and a lot, if it supported explicit byte/bit =
>ordering/packing/aligning =3D
>>> pragmas.
>>>=20
>>> Also, unlike GCC, pointer alignment in Modula-3 is 64bit on x86_64. =
>It =3D
>>> is 32bit in GCC, and x86_64 is totally happy with it. Wr have 64bit =
>so =3D
>>> we must write piece of software in C to be what? Compatible with =
>API's =3D
>>> all systems are compatible with without any hassle.=3D20
>>>=20
>>> TIA
>>> --
>>> Divided by a common language
>>>=20
>>> Dragi=3D9Aa Duri=3DE6
>>> dragisha at m3w.org
>>>=20
>
>
>--Apple-Mail=_97F57BF6-5A6D-479B-8575-88C17BAE93B4
>Content-Transfer-Encoding: quoted-printable
>Content-Type: text/html;
> charset=utf-8
>
><html><head></head><body style=3D"word-wrap: break-word; =
>-webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I =
>have RTInfo module we developed years ago to parse .M3WEB. Good enough? =
>:) But, not a solution, it is easier to write as I wrote in example I =
>used to illustrate problem.<div><div><br></div><div>GCC not obeying =
>packing instructions is like=E2=80=A6 GCC not working in lot of cases. =
>For some reason, I don't believe in it.</div><div><br></div><div>Hint, =
>gm2 is GCC based compiler. And supports very precise packing/aligning =
>rules.</div><div><br><div apple-content-edited=3D"true">
><span class=3D"Apple-style-span" style=3D"border-collapse: separate; =
>color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; =
>font-variant: normal; font-weight: normal; letter-spacing: normal; =
>line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: =
>0px; text-transform: none; white-space: normal; widows: 2; word-spacing: =
>0px; -webkit-border-horizontal-spacing: 0px; =
>-webkit-border-vertical-spacing: 0px; =
>-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
>auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span =
>class=3D"Apple-style-span" style=3D"border-collapse: separate; color: =
>rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: =
>normal; font-weight: normal; letter-spacing: normal; line-height: =
>normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; =
>text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; =
>-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
>0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
>auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div =
>style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
>-webkit-line-break: after-white-space; "><div>--</div><div>Divided by a =
>common language</div><div><br></div><div>Dragi=C5=A1a =
>Duri=C4=87</div><div><a =
>href=3D"mailto:dragisha at m3w.org">dragisha at m3w.org</a></div><div><br></div>=
></div></span><br class=3D"Apple-interchange-newline"></span><br =
>class=3D"Apple-interchange-newline">
></div>
><br><div><div>On Aug 23, 2012, at 9:51 PM, Mika Nystrom wrote:</div><br =
>class=3D"Apple-interchange-newline"><blockquote =
>type=3D"cite"><div><br>Well I don't think Jay said that bytes couldn't =
>be unpacked in Modula-3<br>(you can just use Word for that).<br><br>But =
>I think the point was that a compiler back-end might not =
>necessarily<br>obey your packing instructions?<br><br>Here's what I =
>think you should do... it would be super useful, both to<br>you and =
>other people in the future. And completely independent =
>of<br>compilers.<br><br>Write a something-or-other that uses m3tk to =
>read your RECORD type<br>spec, plus pragmas of your own choice (or =
>comments, or auxiliary data<br>from somewhere) and then generates code =
>using Word.T that can process<br>byte streams and return the RECORD you =
>declared, in portable Modula-3.<br>I doubt it's very difficult. =
> m3tk is cool!<br><br> =
> Mika<br><br>=3D?utf-8?Q?Dragi=3DC5=3DA1a_Duri=3DC4=3D87?=
>=3D writes:<br><blockquote type=3D"cite"><br></blockquote><blockquote =
>type=3D"cite">--Apple-Mail=3D_8871A9FB-3130-4B36-8524-F6549A5CEC9E<br></bl=
>ockquote><blockquote type=3D"cite">Content-Type: =
>multipart/alternative;<br></blockquote><blockquote type=3D"cite"><span =
>class=3D"Apple-tab-span" style=3D"white-space:pre"> =
></span>boundary=3D"Apple-Mail=3D_2314A877-555E-4BDE-8112-C875A2AE5122"<br>=
></blockquote><blockquote type=3D"cite"><br></blockquote><blockquote =
>type=3D"cite"><br></blockquote><blockquote =
>type=3D"cite">--Apple-Mail=3D_2314A877-555E-4BDE-8112-C875A2AE5122<br></bl=
>ockquote><blockquote type=3D"cite">Content-Transfer-Encoding: =
>quoted-printable<br></blockquote><blockquote type=3D"cite">Content-Type: =
>text/plain;<br></blockquote><blockquote type=3D"cite"><span =
>class=3D"Apple-tab-span" style=3D"white-space:pre"> =
></span>charset=3Dwindows-1250<br></blockquote><blockquote =
>type=3D"cite"><br></blockquote><blockquote type=3D"cite">I have a =
>friend, working for large software company and he just recently =
>=3D<br></blockquote><blockquote type=3D"cite">ported some message router =
>from SPARC to Linux/Intel=3D85 Lots of "network =
>=3D<br></blockquote><blockquote type=3D"cite">order" data, same as with =
>my current projects. Network, communication in =
>=3D<br></blockquote><blockquote type=3D"cite">general, network order is =
>everywhere.<br></blockquote><blockquote =
>type=3D"cite"><br></blockquote><blockquote type=3D"cite">Insisting on =
>some god-given data ordering is a bit=3D85 What is nice word =
>=3D<br></blockquote><blockquote type=3D"cite">here? :) Outlandish? =
>Outimeish?<br></blockquote><blockquote =
>type=3D"cite"><br></blockquote><blockquote type=3D"cite">This is not =
>first time I started discussion like this here. Every single =
>=3D<br></blockquote><blockquote type=3D"cite">time Jay explains to me =
>how Modula-3 cannot handle it. I am handling it, =
>=3D<br></blockquote><blockquote type=3D"cite">as I have shown in my =
>example, with Modula-3 code. With a bit of effort =
>=3D<br></blockquote><blockquote type=3D"cite">I can make it =
>almost-transparent (subfolder/platform) over various =
>=3D<br></blockquote><blockquote type=3D"cite">platforms. Of course, as I =
>am developing a full product (not software to =
>=3D<br></blockquote><blockquote type=3D"cite">be run on arbitrary =
>platform) I don't have to worry about too many =
>=3D<br></blockquote><blockquote type=3D"cite">platforms. One is enough =
>here, but I still think Modula-3 can benefit, =
>=3D<br></blockquote><blockquote type=3D"cite">and a lot, if it supported =
>explicit byte/bit ordering/packing/aligning =
>=3D<br></blockquote><blockquote =
>type=3D"cite">pragmas.<br></blockquote><blockquote =
>type=3D"cite"><br></blockquote><blockquote type=3D"cite">Also, unlike =
>GCC, pointer alignment in Modula-3 is 64bit on x86_64. It =
>=3D<br></blockquote><blockquote type=3D"cite">is 32bit in GCC, and =
>x86_64 is totally happy with it. Wr have 64bit so =
>=3D<br></blockquote><blockquote type=3D"cite">we must write piece of =
>software in C to be what? Compatible with API's =
>=3D<br></blockquote><blockquote type=3D"cite">all systems are compatible =
>with without any hassle.=3D20<br></blockquote><blockquote =
>type=3D"cite"><br></blockquote><blockquote =
>type=3D"cite">TIA<br></blockquote><blockquote =
>type=3D"cite">--<br></blockquote><blockquote type=3D"cite">Divided by a =
>common language<br></blockquote><blockquote =
>type=3D"cite"><br></blockquote><blockquote type=3D"cite">Dragi=3D9Aa =
>Duri=3DE6<br></blockquote><blockquote type=3D"cite"><a =
>href=3D"mailto:dragisha at m3w.org">dragisha at m3w.org</a><br></blockquote><blo=
>ckquote =
>type=3D"cite"><br></blockquote></div></blockquote></div><br></div></div></=
>body></html>=
>
>--Apple-Mail=_97F57BF6-5A6D-479B-8575-88C17BAE93B4--
>
>--Apple-Mail=_6458BB99-E0EF-4A10-A66A-491737830F8E
>Content-Transfer-Encoding: 7bit
>Content-Disposition: attachment;
> filename=signature.asc
>Content-Type: application/pgp-signature;
> name=signature.asc
>Content-Description: Message signed with OpenPGP using GPGMail
>
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG/MacGPG2 v2.0.18 (Darwin)
>
>iQEcBAEBAgAGBQJQNou3AAoJEJtljYXUJo8xhFQH/19LV/No97WCrAPygnWWZAa4
>DQDZtnFZuDhAxMut8QZWIZN/LikLsaC39Rd9YMr01oKRZ93gucjUigwad5cPfyUb
>XUV0PNrjMr67TZo9zRcwuXZJp8FzvNDFsA1nOtorQbIPG3e5IaLNdLpihSGBJ3zt
>vnd3wUjnPz56HbdDulA4kYkyxSkCQgJ457jI2DTR+wtsaqNREEl0Hzs1qlpDDXWC
>ShRvTdiDGZV/TMHHwkkWRVjZkHHu3npPClhXzY0fBRXUu+k3NWzZbuzIhXofCJ9y
>C+yLl7qKdtU5cF+JpObPReA2ZfarW7AJ7rLLHZJa6NCs75qtCzo68JWhY8MtF3Y=
>=OiB3
>-----END PGP SIGNATURE-----
>
>--Apple-Mail=_6458BB99-E0EF-4A10-A66A-491737830F8E--
More information about the M3devel
mailing list