> But, if I recall, it only stores the name if it's > altered, not if it's created... which is just what I want. (But I'm > going to have to test that...!)
Wrong. It treats "created" the same as "changed". No good. I think I shall use it anyway to save a list of names changed. Then the next time the script is loaded, test the saved list against _z_ to look for clashes. Inelegant... but workable, I think. On Sun, Oct 9, 2011 at 9:52 PM, Ian Clark <[email protected]> wrote: > 4!:5 (Name Changed) ... that's what I'm looking for. > > Silly of me, because I'd used it before, in another context, and > forgotten about it. > > If I recall though, it isn't really "changed" but "overwritten" (maybe > with the same). But, if I recall, it only stores the name if it's > altered, not if it's created... which is just what I want. (But I'm > going to have to test that...!) > > A temporary lockdown of existing _z_ would be nice. But I need it > mainly for non-pronouns. And plan to migrate it to J7. > > > On Sun, Oct 9, 2011 at 9:34 PM, Dan Bron <[email protected]> wrote: >> Couple of points. You can detect name changes with 4!:5 [1] and the names >> returned will be fully qualified, meaning you'll be able to identify what >> locale the changed name is in. I'm not in front of an interpreter right >> now, but it's something along the lines of: >> >> 4!:5&.>i.2 NB. Top of script >> NB. Body of script >> 'A B'=.4!:5&.>i._2 NB. End of script >> assert 0 = #expected_z_names -.~ (#~(,'z')=(}.~1+i:&'_')@:}:&.>) B >> >> Also, FYI, J has an undocumented feature that allows the definitions of >> names to be locked. That is, names can be assigned once, then marked as >> read-only. You could leverage this feature to query all the names in the z >> locale (in its unaltered state, before you load your script), then set them >> as readonly: subsequent assignment to these names would fail with a a >> 'readonly data' error. Like so (again untested because there is no J for >> the iPad and jum is down): >> >> require 'jmf' >> 1 readonly_jmf_&.> namelist_z_ i. 4 >> >> Well, with one caveat: you have to use J601, or only care about locking the >> definitions of nouns (ie replace i.4 with 0). J602 introduced a change that >> prevents that and later versions from locking the definitions of >> non-pronouns (or really getting under the covers of non-pronouns for any >> reason). For details, see [2]. >> >> -Dan >> >> [1] Definition of 4!:5 : http://www.jsoftware.com/help/dictionary/dx004.htm#5 >> >> 4!:5 y Names Changed. 4!:5]0 turns off data collection; 4!:5]1 turns it on >> and produces a list of global names assigned since the last execution of >> 4!:5 . >> >> [2] Readonly names and 15!:6: >> http://www.jsoftware.com/pipermail/general/2008-November/032554.html >> >> >> >> >> >> On Oct 9, 2011, at 1:28 PM, Ian Clark <[email protected]> wrote: >> >>> It's not the top-level call that's the worry. It's all the little >>> "specials" I put in _z_ myself. >>> >>> >>> On Sun, Oct 9, 2011 at 6:16 PM, Henry Rich <[email protected]> wrote: >>>> I try when possible to avoid exporting function names. If the user >>>> wants to run finesse in the package bridge, he can write >>>> >>>> finesse_bridge_ >>>> >>>> can't he? If he wants to cover that with a name in z, that's his business. >>>> >>>> Henry Rich >>>> >>>> On 10/9/2011 12:57 PM, Ian Clark wrote: >>>>> That's the long way round. (I reckon I can do that.) >>>>> >>>>> I only need the warning (for the end-user). Plus maybe the names >>>>> clashed (for the customer to give to the helpline). >>>>> The aim is to help with new customers hitting time-consuming >>>>> installation problems. >>>>> >>>>> >>>>> 2011/10/9 Björn Helgason<[email protected]>: >>>>>> Do you need to get a copy of all the objects? >>>>>> >>>>>> Would it be enough to have a database with information about the objects? >>>>>> >>>>>> In the case of verbs you could place a copy of the visual representation >>>>>> of >>>>>> the verb into a noun and take its vital info into the database. >>>>>> >>>>>> You could then put a time stamp on the info when you registered the info. >>>>>> >>>>>> 2011/10/9 Ian Clark<[email protected]> >>>>>> >>>>>>> As a (paranoid?) safety device in a "fit'n'forget" utility, I'm trying >>>>>>> to write code to go in a given script which will warn when that script >>>>>>> will unintentionally alter -- or has altered -- an existing name in >>>>>>> the _z_ locale. >>>>>>> >>>>>>> NB: "alter", not merely "overwrite" -- though a slick way of detecting >>>>>>> overwrite would be worth knowing too. APL+Win attaches a timestamp to >>>>>>> each fn, which makes this task easy. >>>>>>> >>>>>>> It would be nice not to have to maintain -- by-hand -- an explicit >>>>>>> list up-front, of names created by the script. >>>>>>> >>>>>>> An allied question: how best can I "snapshot" a given locale -- such >>>>>>> as _z_? That is: create a second temporary locale _sav_ with identical >>>>>>> contents? I can only think of brute-force: enumerating the names in >>>>>>> _z_ and copying them one-by-one to _sav_. >>>>>>> ---------------------------------------------------------------------- >>>>>>> For information about J forums see http://www.jsoftware.com/forums.htm >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Björn Helgason, Verkfræðingur >>>>>> Fornustekkum II >>>>>> 781 Hornafirði, >>>>>> t-póst: [email protected] >>>>>> gsm: +3546985532 >>>>>> twitter: @flugfiskur >>>>>> http://groups.google.com/group/J-Programming >>>>>> >>>>>> >>>>>> Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans >>>>>> >>>>>> góður kennari getur stigið á tær án þess að glansinn fari af skónum >>>>>> /|_ .-----------------------------------. >>>>>> ,' .\ / | Með léttri lund verður | >>>>>> ,--' _,' | Dagurinn í dag | >>>>>> / / | Enn betri en gærdagurinn | >>>>>> ( -. | `-----------------------------------' >>>>>> | ) | (\_ _/) >>>>>> (`-. '--.) (='.'=) ♖♘♗♕♔♙ >>>>>> `. )----' (")_(") ☃☠ >>>>>> ---------------------------------------------------------------------- >>>>>> For information about J forums see http://www.jsoftware.com/forums.htm >>>>> ---------------------------------------------------------------------- >>>>> For information about J forums see http://www.jsoftware.com/forums.htm >>>> ---------------------------------------------------------------------- >>>> For information about J forums see http://www.jsoftware.com/forums.htm >>> ---------------------------------------------------------------------- >>> For information about J forums see http://www.jsoftware.com/forums.htm >> >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
