Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by h1439878.stratoserver.net (8.14.2/8.14.2/Debian-2build1) with ESMTP id r6NMUwWC027653 for ; Wed, 24 Jul 2013 00:30:59 +0200 Received: from relay2.uni-heidelberg.de ([129.206.210.211]) by mx-ha.gmx.net (mxgmx105) with ESMTP (Nemesis) id 0M9uzs-1Uqnoq2EbA-00B3mi for ; Wed, 24 Jul 2013 00:30:52 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id r6NMRqcU011003 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 24 Jul 2013 00:27:52 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [127.0.0.1]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id r6NM12an013025; Wed, 24 Jul 2013 00:27:51 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 10292382 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Wed, 24 Jul 2013 00:27:51 +0200 Received: from relay.uni-heidelberg.de (relay.uni-heidelberg.de [129.206.100.212]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id r6NMRp8T014422 for ; Wed, 24 Jul 2013 00:27:51 +0200 Received: from mail-pb0-f44.google.com (mail-pb0-f44.google.com [209.85.160.44]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id r6NMRbAk010615 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Wed, 24 Jul 2013 00:27:41 +0200 Received: by mail-pb0-f44.google.com with SMTP id uo1so8928208pbc.31 for ; Tue, 23 Jul 2013 15:27:37 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.66.9.71 with SMTP id x7mr40416173paa.37.1374618457122; Tue, 23 Jul 2013 15:27:37 -0700 (PDT) Received: by 10.66.150.226 with HTTP; Tue, 23 Jul 2013 15:27:36 -0700 (PDT) References: <51ECE2AC.7020806@morningstar2.co.uk> <51ED4B60.8040900@morningstar2.co.uk> Content-Type: text/plain; charset=ISO-8859-1 Message-ID: Date: Tue, 23 Jul 2013 18:27:36 -0400 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Bruno Le Floch Subject: Re: Propagation of 'global'ness To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE In-Reply-To: Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: Envelope-To: X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=V3; X-GMX-Antivirus: 0 (no virus found) X-UI-Filterresults: notjunk:1;V01:K0:Fie2FmeYuA0=:R4lkR4DpHSnk2PIQbH4kEdSlZu 5O0o3PPoi4ICzPL5pei85mUDCqumcuhiDiw+vLDHvKe4nOwN9M9NmkZvhA0lNhs5wKHnCllQ2 sfmTn7oe7BHDnW9s+5JqY/0HQaK99CF6EO5Q4VTFtiRRsX/wxV6VzMu6m/U//ERd/uq1c3+oS o6iSUG/A1VVlBhxKfAeQ6PlX/xvNrQV11smaqhJ15DteDUEzAKVvLXn8CIeScQqVwgztHCNna GzIAmK236Fw+fJynK8WX+QqXXeePGNRcY+ipHjhkhXklhRscXQxgKy+rMPS5nAE8Y+4/9k2zY nSOmFkDWq4iu8Rfo7I+vAxiHJGI2aWs5uxrV1xKwwnEiVtuGbiQRx5i9L8MtMlvYD830t2SGI 4oalm437Pz4/WanOPejWlrwv+1b0+GVlxkc5o6IF8AJ52DMYfwjZOSZDbvoXtVRZdAmvWuzJP ZY22kUtMFbxTkvWkv5y890J+9ID064Cm8oq0kssvOBF9NAiCzgcjw4mNpmU5Obi/22Q4XnzRF 9kB1RydCT2Di+nFoedKwtPMTu2tj/AVAcd9htTOK827MJstkG3tZ/6KoU9bFiAEL4URrnlACt U9qvFKePziqIEXWZ6S9OzoKoBpXaWXU+jrWE50riC7AINq4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Keywords: X-UID: 7276 We are moving away from the original question, which was how to keep track of the scope. I would argue that functionality equivalent to the proposed \prop_sput:NNnn exists, as \use:c { prop_#1put:Nnn } with #1 being either { } or { g }. For instance, applying this approach (which is IIRC used in l3keys) to the prop example you gave, we would obtain \cs_new_protected_nopar:Npn \prop_put:Nnn { \@@_put:nNnn { } } \cs_new_protected_nopar:Npn \prop_gput:Nnn { \@@_put:nNnn { g } } \cs_new_protected:Npn \@@_put:NNnn #1#2#3#4 { \tl_set:Nn \l_@@_internal_tl { \s_@@ \tl_to_str:n {#3} \s_@@ { \exp_not:n {#4} } } \@@_split:NnTF #2 {#3} { \use:c { tl_ #1 set:Nx } #2 { \exp_not:n {##1} \l_@@_internal_tl \exp_not:n {##3} } } { \use:c { tl_ #1 put_right:Nx } #2 { \l_@@_internal_tl } } } In low-level code such as this one, I prefer the current approach because it is faster. In higher-level code such as third-party packages, the \use:c approach seems fine to me. The drawback of \use:c will appear if we ever want to attempt some static analysis of the code (if only to know which function requires which, or how to properly indent code), as it is very hard to find out that \tl_set:Nx is called in the above. But I think that it is not such a huge drawback, as it is already unlikely that we can extract much meaningful information from TeX code anyways. I see the other approach (adding 'sput' functions) as having a larger drawback, as it requires adding hundreds of functions (including the inevitable variants). >> I've no real experience of other languages, though, so perhaps I miss >> something. What does one do in say C if the data structures available >> are not suitable? (I didn't think you could even add keywords in most >> languages, so adding data types seems tricky.) > > C is quite old, but even C allows the creation of new datastructures > and control-flow constructs. New keywords can be added with > preprocessor directives (which are very close to TeX command > sequences, actually; both are often referred to as macros). > > What C lacks is encapsulation. Like LaTeX, it has to rely on goodwill > and convention to prevent conflicts. C++ fixed this (somewhat). I think C's structs can be completely emulated using a prop in expl3: of course, that leads to an overhead as the names of the struct entries are stored with the data. Some object ideas I am working on at the moment would alleviate that, storing the entry names once for all structs of the same type. C pointers cannot easily be emulated, as one needs the ability to create unique names (cf. another recent discussion where we concluded that providing a function for that purpose was best). Am I missing some goodies that C provides? While we are talking of datastructure, hence are not very far from objects, let me ask a question: do we want function polymorphism? In other words, do we want the ability for a function to switch behavior depending on the type of its argument, e.g., letting us provide \obj_to_str:N ? Some somewhat-object-oriented languages do not allow this, for instance OCaml will balk at "1.2 + 3.4", and will require "+." instead of "+" for floating points. >> [BTW, I'd hope expl3 is used for 'typesetting', broadly :-) Bruno may >> want to pilot the Mars rover in TeX, but ...] > > TeX is Turing Complete. If you won't exploit it, someone else will. > > Enhanced programming tools help us to build packages that ultimately > make life easier for authors. Below that level, treating TeX like a > general purpose language makes a lot of sense. Isn't that why you guys > are creating expl3 in the first place, and why dialects like LuaTeX > exist? Yes, TeX is Turing Complete, and we do make use of it. One question is to know if we want to go much beyond what C provides (I think we are not very far from covering that) in terms of general-purpose programming tools. Remember that beyond this we also need to worry about tools to handle many other aspects ranging from setting options on a document-wide, environment-wide, or otherwise local basis, taking care of fonts, building paragraphs, maths formulas, tables, and pages from all this, as well as placing figures, understanding the correct approach for letting the user control their placement, etc. There is more than just programming. -- Bruno