Git Product home page Git Product logo

Comments (15)

resuna avatar resuna commented on July 2, 2024

This is expected behaviour. "get" returns a list of requested fields.

Try this:

positions share set moo {1234 5678 23423}
positions share set woof 1234
positions share get moo woof
ok {{1234 5678 23423} 1234}

You're being led astray by the fact that the printable form of a single-element list is the same as the first element.

from speedtables.

bovine avatar bovine commented on July 2, 2024

Make "share get" not introduce extra list around the value if it is already a list and only one value is being requested.

[master 38f110c] Make "share get" not introduce extra list around the value if it is already a list and only one value is being requested. (issue 12)
3 files changed, 41 insertions(+), 2 deletions(-)

from speedtables.

bovine avatar bovine commented on July 2, 2024

hmm, didn't see your post before I committed... Let me consider that.

from speedtables.

bovine avatar bovine commented on July 2, 2024

I did notice that "share get" allows requesting multiple values when I was making my fix. My above commit makes it return a single value if you are requesting only one variable, or the old behavior if requesting 2 or more values. What do you think about that?

from speedtables.

resuna avatar resuna commented on July 2, 2024

Changing it will break any existing code that uses the idiom [lindex [$table get key] 0]. I know I've written code that uses it. None of my code that does is live any more, but I would be surprised if there was no code in all of Flightaware that used it.

from speedtables.

resuna avatar resuna commented on July 2, 2024

Karl and I have discussed this before and decided that the existing behavior was less surprising than having the result change from an element to a list depending on the number of elements requested.

from speedtables.

bovine avatar bovine commented on July 2, 2024

Actually, FA doesn't use any other shared memory speedtables currently. I can change it back if we think it's better that way though... It just seemed more convenient to avoid needing to use lindex/lassign if you're only requesting one variable.

from speedtables.

resuna avatar resuna commented on July 2, 2024

You're not just changing shared memory ctables. This change effects all ctables code, and also needs to be changed in master-server ctables and stapi.

from speedtables.

resuna avatar resuna commented on July 2, 2024

It also creates an inconsistency between "table get" and "table search -get".

from speedtables.

bovine avatar bovine commented on July 2, 2024

okay you have some good arguments, so I've restored the original behavior.

However, I don't seem to actually be able to use "share get" for a non shmem table. It always returns empty string.

package require speedtable

CExtension bullseye 1.0 {
    CTable Barn {
        varstring alpha
        varstring beta indexed 1
        varstring delta
        varstring gamma
    }
}

package require Bullseye
Barn create mybarn

mybarn share set alpha alfa
if {[mybarn share get alpha] != [list "alfa"]} {
    error "mismatch1"
}
mybarn share set beta "bovo bravo"
if {[mybarn share get beta] != [list "bovo bravo"]} {
    error "mismatch2"
}
mybarn share set delta deltalina gamma "gamma gamma gamma"
if {[mybarn share get gamma] != [list "gamma gamma gamma"]} {
    error "mismatch3"
}
if {[mybarn share get beta delta] != [list "bovo bravo" "deltalina"]} {
    error "mismatch4"
}

from speedtables.

resuna avatar resuna commented on July 2, 2024

Aha, I get it! I'm mixing up "share get" with "get". You're right, the "share" command is only there for shared memory ctables. It should be an error for everything else.

How are you using "share set" and "share get"? What are you using them for?

from speedtables.

resuna avatar resuna commented on July 2, 2024

Anyway, for the "share get" command, I don't see anything that would actually break with your change, but it's a change that makes me nervous.

from speedtables.

resuna avatar resuna commented on July 2, 2024

On further thought I would be happier making "share get" not even accept more than one argument, rather than break the symmetry of a list and a single value.

from speedtables.

bovine avatar bovine commented on July 2, 2024

good point. I've made a commit to make all "share" commands now return error rather than silently doing nothing:

[master 64f322e] make "share" commands return error (not TCL_OK) when invoked on a non-shared table.
1 files changed, 4 insertions(+), 2 deletions(-)

I'm using the "share set/get" for communicating the last replayed timestamp from the master to the readers. This works well for small variables that are not complex enough to warrant a dedicated speedtable.

I think I will change "share get" to only accept one argument, and then add a "share multiget" to let you specify multiple arguments and get the old behavior...

from speedtables.

bovine avatar bovine commented on July 2, 2024

[master a1e1a50] make "share get" accept only one argument, add "share multiget" for multiple arguments and returning a list. (Issue 12)
4 files changed, 91 insertions(+), 16 deletions(-)

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.