Skip to content

Suggestion: Possible shorthand for indicating variables are Signals #2

@shiroinegai

Description

@shiroinegai

This is probably a controversial suggestion but would it possibly be a good idea for Signals to be represented by a double underscore suffix like so?

const foo__ = useSignal(0)

console.log(foo__.value)

A cursory search doesn't bring up much usage of trailing double underscores in general and it would be a much terser way to convey that a variable is a Signal if adopted. Considering how much Signals will be used for any Qwik project, I think it's reasonable to not type out "Signal" in full each and every time.

Another reason why I'm suggesting this is that the general convention for variable names are usually in camelCase and suffixing "Signal" to them just blends in with everything else, making it hard to scan your code for Signals by eye.

Since the intention is to explicitly indicate that a variable represents a Signal, it could also be represented with an extra underscore like so:

const bar_Signal = useSignal(0)

console.log(bar_Signal.value)

In both examples, the extra optical space between the actual names of the variables (foo and bar) and the indicators (__ and _Signal) make it more visually clear that the variables are Signals. An example to bring the point across:

// with "Signal" suffix
const contrivedVariableWithLongNameSignal = useSignal(0)

console.log(contrivedVariableWithLongNameSignal.value)



// with double underscores suffix
const contrivedVariableWithLongName__ = useSignal(0)

console.log(contrivedVariableWithLongName__.value)



// with "_Signal" suffix
const contrivedVariableWithLongName_Signal = useSignal(0)

console.log(contrivedVariableWithLongName_Signal.value)

Just as an aside, the first example would possibly work better for people with a preference for snake_case variables (which seems to be slowly growing in popularity) since suffixing "signal" would similarly blend in for them. Though I suppose in snake_case, capitalising "Signal" would be enough to make them easily scannable.

This is just a suggestion and I don't have strong opinions about it, just putting it out there for consideration!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions