APL in its ghetto (?) - Programming Languages

This is a discussion on APL in its ghetto (?) - Programming Languages ; TaliesinSoft a écrit : [color=blue] > It seems to me that one ought to be able to write > > A.B <- 5 > > and if at the time A is undefined a namespace will be created. > > ...

+ Reply to Thread
Page 3 of 12 FirstFirst 1 2 3 4 5 ... LastLast
Results 21 to 30 of 115

APL in its ghetto (?)

  1. Default Re: APL in its ghetto (?)

    TaliesinSoft a écrit :
    [color=blue]
    > It seems to me that one ought to be able to write
    >
    > A.B <- 5
    >
    > and if at the time A is undefined a namespace will be created.
    >
    > My question is whether in this case there is any ambiguity in doing so,[/color]


    You could of course have some difficulty locating an error if you heve
    mistyped an identifier somewhere, a classic problem with
    autovivification of names.

  2. Default Re: APL in its ghetto (?)

    Paul Mansour a écrit :
    [color=blue]
    > Jim,
    >
    > Interesting question. Couple of observations:
    >
    > What about A.B.C.D <-5, where A exists, but not B C and D?[/color]

    Autovivification of all of them, non ?

    Except of course is the question asked to the system is whether A.B.C.D
    /exists/ ;-)

    [color=blue]
    > It may be that asking the interpreter to create a namespace for you as
    > you try to stuff something in non-existing space is equivalent to
    > allowing the expression A[1]<-5 to work even if A does not exist.[/color]

    A nice thing, indeed, because in that case there is nothing more to
    distinguish an *integer(s)-indexed* array and a *string(s)-indexed*
    array. In fact, both could in such a case be mixed with the same array
    name, the problem being the following one, with a non-existing A :

    A[2 3 5]<- 11 22 33

    do we have 5=rho A (seems reasonable) or 3=rho A ?

    A['Paris' 'Rome']<- 'France' 'Italy'

    What is rho A in such a case ?

    And what if apply the second operation on the first A rather than on an
    empty name ? Interesting questions, and the difficulty is probably not
    to solve them, but to solve them with elegance.

  3. Default Re: APL in its ghetto (?)

    The scripting Dictionary object, usable with APL+Win, APL/W, and APX,
    already provides a mechanism for creating a collection of name/value pairs
    where name is a string and value is either a leteral or numeric.


  4. Default Re: APL in its ghetto (?)

    On Thu, 29 Dec 2005 07:55:51 -0600, Paul Mansour wrote (in article
    <1135864551.834839.298880@g47g2000cwa.googlegroups.com>):
    [color=blue]
    > Jim,
    >
    > Interesting question. Couple of observations:
    >
    > What about A.B.C.D <-5, where A exists, but not B C and D?[/color]

    A, in that case, would have to be a namespace. But if both A and B were
    already defined as namespaces then, as I would like things, C would become a
    namespace and D a variable.
    [color=blue]
    > It may be that asking the interpreter to create a namespace for you as you
    > try to stuff something in non-existing space is equivalent to allowing the
    > expression A[1]<-5 to work even if A does not exist.[/color]

    In my own world, and unfortunately not that of the seeming remainder of the
    community of APL implementors (shame on me!), the bracket notation describes
    a qualification on an existing object, in this case A.
    [color=blue]
    > Would certainly be nice if we could create new namespaces without the []NS
    > '' though.[/color]

    Well, we can create a variable or a function without a system command, so why
    not a namespace?

    --
    James L. Ryan -- TaliesinSoft


  5. Default Re: APL in its ghetto (?)

    On Thu, 29 Dec 2005 08:39:51 -0600, FDA wrote
    (in article <43b3f45b$0$3785$79c14f64@nan-newsreader-07.noos.net>):

    [in response to my stating the following]
    [color=blue][color=green]
    >> In Dyalog APL I can do the following
    >>
    >> a) Create a namespace CC with the appropriate system command or system
    >> function
    >>
    >> b) Assign variables within CC
    >>
    >> CC.US <- 1
    >> CC.CA <- 1
    >> CC.AU <- 61
    >> CC.BR <- 55
    >>
    >> c) look up country code for a given country
    >>
    >> CC.US
    >> 1
    >> CC.BR
    >> 55[/color]
    >
    > Fine, Jim, but what do you do if you want to index with plain strings,
    > without restrictions ? I guess
    >
    > CC.'United States of America' will not do :-(
    >
    > We just *cannot* ask people to code their information as we had to to in
    > the 60s and 70s, mostly because a good part of the information they want
    > to deal with comes directly from the Internet.[/color]

    If we wish to index with plain strings we can create a matrix where, say, the
    first column contains the indexing strings and the second column contains the
    associated value. It is then a simple task to perform an index search on that
    first column and use the resulting value of that search to extract the value
    in the second column.

    If this is to be a commonly performed action it is a trivial matter to write
    APL functions that act as surrogates for the missing primitive capability.

    One of the joys of APL is the ease with which one can create defined
    functions that in effect extend the language beyond the built-in
    capabilities.

    --
    James L. Ryan -- TaliesinSoft


  6. Default Re: APL in its ghetto (?)

    > On Wed, 28 Dec 2005 10:57:24 -0600, Christopher Browne wrote[color=blue]
    > (in article <m3k6dpnoqz.fsf@mobile.int.cbbrowne.com>):
    >[color=green]
    >> In Perl, I can specify an associative array of country telephone
    >> prefixes, thus:
    >>
    >> $CC{"US"} = "1";
    >> $CC{"CA"} = "1";
    >> $CC{"AU"} = "61";
    >> $CC{"BR"} = "55";
    >> $CC{"FR"} = "33";
    >> $CC{"HK"} = "852";
    >> $CC{"IN"} = "91";
    >> $CC{"IE"} = "972";
    >> $CC{"JP"} = "81";
    >> $CC{"UK"} = "44";
    >>
    >>
    >> And later, look up the country code for a given country
    >>
    >> $x = $CC{$some_country};[/color]
    >
    > In Dyalog APL I can do the following
    >
    > a) Create a namespace CC with the appropriate system command or system
    > function
    >
    > b) Assign variables within CC
    >
    > CC.US <- 1
    > CC.CA <- 1
    > CC.AU <- 61
    > CC.BR <- 55
    >
    > c) look up country code for a given country
    >
    > CC.US
    > 1
    > CC.BR
    > 55[/color]

    What you're describing seems to require that the country name be
    referenced in the text of the program.

    How do I evaluate the country code if I just have the string...

    C = 'US'

    In the various other languages, I can use something like:
    $area_code = $CC{$country}
    --
    (format nil "~S@~S" "cbbrowne" "acm.org")
    [url]http://linuxdatabases.info/info/x.html[/url]
    Rules of the Evil Overlord #67. "No matter how many shorts we have in
    the system, my guards will be instructed to treat every surveillance
    camera malfunction as a full-scale emergency."
    <http://www.eviloverlord.com/>

  7. Default Re: APL in its ghetto (?)

    On Thu, 29 Dec 2005 08:48:36 -0600, FDA wrote
    (in article <43b3f667$0$3791$79c14f64@nan-newsreader-07.noos.net>):
    [color=blue]
    > Why use the dot when the bracket already exists ?
    >
    > CC['US' 'CA' 'AU' 'BR'] <- 1 1 61 55
    >
    > It seems *much* more user-friendly, as the concept is exactly parallel
    > to what we already have with regular APL indexing, and so does not need
    > to learn a syntax addition. It is just extended with backwards
    > compatibility (except that what caused one a "syntax error" does not
    > anymore. Remember the "NONCE ERROR" at the beginning of APL\360?[/color]

    My reply was in the context of what is currently available in Dyalog APL.

    And, speaking of "NONCE ERROR", I'm reminded of the dreaded "IMPLICIT ERROR"
    that at one time existed in a number of APLs, emerging when one used a
    localized system variable prior to that variable having been the recipient of
    an assigned value post localization. We took a different approach with
    Burroughs APL\700 and automatically set the value of a localized system
    variable to the value it had in the calling environment, thus eliminating the
    case where the system variables were without a value. Interestingly this
    notion was initially met with strong resistance by the implementors of other
    APL systems, but it prevailed in the end.

    --
    James L. Ryan -- TaliesinSoft


  8. Default Re: APL in its ghetto (?)

    That is exactly right!

    a{comes from}90

    creates a variable in the DEFAULT namespace #. The statement is exactly
    equivalent to:

    #.a{comes from}90

    When you are attempting to execute a.a{comes from}90, you are NOT using
    the default namespace which is implicitly referred to but referring to a
    namespace named <a>: if it does not exist, the response should be VALUE
    ERROR, just as when you reference a variable/function that does not
    exist.

    Omission of a named nameshace defaults the scope to the DEFAULT namespace:
    if you specify a namespace and it does not exist, what do you expect if not
    VALUE ERROR?

    What would you expect when saving a document to f:\xx\mydoc.txt if f: does
    not exist, if xx does not exist or if neither of them can possibly exist?
    With a.a{comes from}90, it is conceivable that <a> cannot POSSIBLY exist
    either because there is no memory []wa to create it or because it is
    already in use as another object in the active session.


  9. Default Re: APL in its ghetto (?)

    TaliesinSoft a écrit :
    [color=blue]
    > If we wish to index with plain strings we can create a matrix where, say, the
    > first column contains the indexing strings and the second column contains the
    > associated value. It is then a simple task to perform an index search on that
    > first column and use the resulting value of that search to extract the value
    > in the second column.[/color]

    Why not, indeed ? We could also ask users to program in assembly
    language using appropriate subroutines.

    Let us be serious, please. If I have 4000 references to manage, I
    certainly do *not* want to search through them sequentially, much less
    to keep them sorted at a great expense to apply a clumsy dichotomic
    method. *Direct access is what is needed* , no awkward /substitute/ . It
    is also, by the way, what database give us once we go from the
    prototyping to the real application phase, a thing the Perl conceptor(s)
    understood while allowing to "bless" an associative array in order to
    associate it with any database.

    Last but not least, one database <=> one name if we want our programs to
    be readable.

    [color=blue]
    > One of the joys of APL is the ease with which one can create defined
    > functions that in effect extend the language beyond the built-in
    > capabilities.[/color]

    One of the lesser joys is that when you try to merge different APL
    programs that have used different "easy" ways to extend the language,
    you realize you have to duplicate the associated (different, of course)
    functions, to say nothing about the predictible conflict of names used
    to perform similar functions.

    No substitute to introducing basic functions of the mind as basic
    functions of the language too, period. :-(

  10. Default Re: APL in its ghetto (?)

    TaliesinSoft a écrit :

    [color=blue]
    > And, speaking of "NONCE ERROR", I'm reminded of the dreaded "IMPLICIT ERROR"[/color]


    One of my favorites to pull a prank on young engineers (already knowing
    APL, of course) was to write in one of their workspaces when they were
    not present :


    quadLX <- '''quadIO<-''1'''''


    Then watch. It was a *very* good way to test the way they were reasoning :-)


+ Reply to Thread
Page 3 of 12 FirstFirst 1 2 3 4 5 ... LastLast