Git Product home page Git Product logo

Comments (5)

resuna avatar resuna commented on July 2, 2024

This is cool, I've run into this before but didn't go 'you know, that should be possible', but you're right, it should.

I'm thinking this should maybe not be the default, but it could be a ctable option?

Let me think about whether there's any possible breakage from just doing it, rather than making it an option.

from speedtables.

lehenbauer avatar lehenbauer commented on July 2, 2024

I don't mind if it's an option, at all, but if it is an option it needs to flow naturally. I don't want to have to specify "-leadingdash 1" on "set" or "store", although I'm not hard over on it.

As for search, yeah, if search results were to have a leading dash in field names then it would have to be an option. Also the array_get and array_get_with_nulls methods would need a switch, if they were to support it.

It would be real natural to write

$table set $key -field value -field value -field value

We might make it that if the first key has a leading dash, all keys must have a leading dash for that single statement. That'd catch anyone screwing up the key-value pairs.

from speedtables.

resuna avatar resuna commented on July 2, 2024

Oh yeh, it should be a cosmetic filter on set/store, just to allow iTcl/tk style method option assignments. The actual field names wouldn't have the dashes.

What about a different method, perhaps "$table option_set ..."?

from speedtables.

resuna avatar resuna commented on July 2, 2024

I was thinking of making it a class-level (meta-table) option, but we don't seem to have that set up as a general case. The other two possibilities are: it could be an instance option set on the table when it's instantiated, or it could be an option on the method (I agree, that's ugly) or a different method.

from speedtables.

resuna avatar resuna commented on July 2, 2024

OK, I started working on this. Technically, it's easy to implement with a small chunk of code in command-body.c-subst, eg:

    if(optIndex == OPT_SET_OPT) {
        int prefix_state = -1; // 1 if seen '-', 0 if seen without '-'
        for (i = 0; i < listObjc; i+= 2) {
            char *option = Tcl_GetString (objv[i]);
            if(*option == '-') {
                if(prefix_state == 0) {
                    Tcl_AppendResult (interp, "Can't mix prefixed and unprefixed field names", (char *)NULL);
                    return TCL_ERROR;
                }
                prefix_state = 1;
                objv[i] = Tcl_NewStringObj(option+1, -1);
            } else {
                if(prefix_state == 1) {    
                    Tcl_AppendResult (interp, "Can't mix prefixed and unprefixed field names", (char *)NULL);
                    return TCL_ERROR;
                }
                prefix_state = 0;
            }
        }
    }

(with appropriate additions to the list of methods and matching enums)

Problem is with store what to do about "$table opt_store -nocomplain". "nocomplain" is a legal field name.

My call would be: opt_store and opt_set don't take qualifiers, and always act like "-nocomplain", ignoring unknown fields.

from speedtables.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.