Interesting idea.  It seems this could be done without
messing with the parser at all.  What would be the
benefit of a parsed option over an enhancement to the
function?

If extending the functionality of table() is all that
is wanted, you might consider something along the
lines of newlist (posted in July and appended to this
post). Newlist replaces list() in an attempt to get
some consistency with set(). There were some
discussions and a few design enhancements were left
out because they would have been
confusing/inconsistent.

But what would an enhanced table look like?  Why not
just add a second argument to table?  (I don't think
one is used).

table([k1,v1,k2,v2])  # only sets the default 
table(,[k1,v1,k2,v2]) # an obvious choice 
table(,[[k1,v1],...]) # also obvious, but is it useful
table(,table())       # copy ?? error ??
table(,set())         # what should this do?

other types?


David

--- Clint Jeffery <[EMAIL PROTECTED]> wrote:

> 
> >   [Wade] came up with the following: 
> >   newtable := [< "key1": "value1", "key2":
> "value2", "key3": "value3" >] 
> 
> This is not bad... the obvious question is whether
> the < and > are needed...
> 
> >   Where I was tinkering has the characteristic
> that the new literal type is 
> >   down in the Icon code, not the Unicon code. I
> never, in fact, thought to 
> >   look in the Unicon layer. Would it need to know?
> unigram.y looks like it 
> >   would need to (why?). 
> 
> Yes, correct.  If you change Icon's grammar,
> Unicon's grammar needs to the
> same change in order to parse the new construct and
> allow it to "pass through".
> The opposite is not true; a change to Unicon needs
> no change to icont.
> 
> As things stand, you are proposing adding a new VM
> instruction, which is
> much more serious business than adding some new
> syntax or extending a
> built-in function (table()) to support that new
> syntax.
> 
> Clint
> 
> 
>
-------------------------------------------------------
> This SF.Net email is sponsored by the JBoss Inc. 
> Get Certified Today
> Register for a JBoss Training Course.  Free
> Certification Exam
> for All Training Attendees Through End of 2005. For
> more info visit:
>
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
> _______________________________________________
> Unicon-ldif mailing list
> [EMAIL PROTECTED]
>
https://lists.sourceforge.net/lists/listinfo/unicon-ldif
> 
############################################################################
#
#       File:     newlist.icn
#
#       Subject:  Unicon extension for built-in procedure
list
#
#       Authors:  Steve Wampler, David Gamey
#
#       Date:     July 2005
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#   This procedure overrides and extends the built-in
function list().
#
#   list(X) returns X converted to a list, where X is
a table, set, or record 
#
#   list(X,x1,...,xn) returns a list with appended
elements x1,...,xn 
#
#   list(L) returns L (not a copy), where L is a list
#
#   list(L,x1,...,xn) returns a copy of L with
appended elements x1,...,xn 
#
#   otherwise list behaves exactly as the built-in
function
#
#   Notes:
#
#   1.  Returning unmodified lists saves surprises
with garbage collections.
#       It seemed more consistent with other
functions.
#   2.  This now makes list() symmetric functionality
with set().
#   3.  list(T) converts the values of a table to a
list.  
#       To convert the keys of a table, include "link
tables" and 
#       use list(keyset(T)).
#   4.  list(set(...)) is orderless.
#   5.  list(x) was not extended to handle strings
differently than the
#       built-in function because strings are handled
inconsistently and
#       no really useful and compatible interpretation
was obvious.  
#       For example, list("3") returns [,,] and
list("a") generates and error.
#   6.  list() was not extended to csets, because
elements of !csets generate 
#       single character strings.
#   7.  On the surface, this code looks bilingual
(Unicon/Icon) but we suspect
#       it relies on Unicon extensions. 
#
############################################################################


procedure list(x[])                     #: convert
structure to list and append
local L  
static LIST
initial LIST := proc("list",0)

if *x = 0 then return x                 # we already
got one!

case type(x[1]) of {

   "list" :                             # list type
      if *x = 1 then return x[1]        # . return
original if no work
      else L := copy(get(x))            # . make copy
and prepare for work
        
   "table" | "set" :                    # other
structures
      every put(L := [], !get(x))       # . convert
elements to list

   default:
      if image(x[1]) ? ="record " then  # record
structure
         every put(L := [], !get(x))    # . convert
      else                              # null,
numeric (including numeric string)
         return LIST!x                  # . use old built-in
behaviour
}

every put(L,!x)                         # concatenate
any remaining varargs
return L
end




-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
Unicon-group mailing list
Unicon-group@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to