octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accepting arbitrary strings as structure field names


From: Etienne Grossmann
Subject: Re: Accepting arbitrary strings as structure field names
Date: Sat, 4 Nov 2006 22:19:59 -0500
User-agent: Mutt/1.4.2.1i

  Hi all,

On Sat, Nov 04, 2006 at 09:40:38PM -0500, Bill Denney wrote:
# Rafael Laboissiere wrote:
# >Would it be acceptable to remove the restriction of structure field names
# >being valid_identifier?  The benefit of this change is that Octave will 
# >have
# >hash arrays for free, allowing code like this:
# >
# >    var.("@#$%") = 0;
# >  
# I'm guessing that this would be pretty hard to do.  Is there a reason 

would it? With a two-line patch (a check removal, more precisely, see
below), I can do:

octave:5>  var.("@#$%") = 0;
octave:6> var
var =
{
  @#$% = 0
}

Disclaimer: I didn't check for potential trouble brought by the patch.

  Cheers,

  Etienne

====================================================================== 
--- octave-2.9.9/src/pt-idx.cc  2006-06-16 05:09:42.000000000 +0000
+++ octave-2.9.9/src/pt-idx.cc.no_hash_field_check      2006-11-04
19:07:13.000000000 +0000
@@ -203,8 +203,8 @@
            {
              fn = t.string_value ();

-             if (! valid_identifier (fn))
-               ::error ("invalid structure field name");
+             // if (! valid_identifier (fn))
+             //   ::error ("invalid structure field name");
            }
        }
       else
====================================================================== 

# you couldn't restrict your hashing to use base 52 numbers and map them 
# to [A-Za-z]?


# Bill

-- 
Etienne Grossmann ------ http://www.isr.ist.utl.pt/~etienne


reply via email to

[Prev in Thread] Current Thread [Next in Thread]