Skip to content

Proposal improve variable naming #970

@tony9527167

Description

@tony9527167

I used to be a big fan of short variable names, especially in the "short naming family," until I switched my IDE from legacy Turbo C/DOS to modern VSCode on Windows 7. Short, mixed-style naming is friendly to some auto-complete CLI tool or util, but it's terrible for spell checkers.

Image

Proposal: Improve Variable Naming

Keep the original names but mark them as DEPRECATED in version 2.x.x. Introduce new, clearer names and promote them as the standard going forward. Here’s a pseudocode example:

/* The cJSON structure: */
typedef struct cJSON
{
    /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
    struct cJSON *next;
    struct cJSON *prev;

    /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
    struct cJSON *child;

    /* The type of the item, as above. */
    int type;

    /* The item's string, if type == cJSON_String or type == cJSON_Raw */
    /* Deprecated: use value_string instead. */
    char *valuestring;

    /* The value of value_string is the same as valuestring. */
    char *value_string;

    /* Writing to valueint is DEPRECATED. Use cJSON_SetNumberValue instead. */
    int valueint;

    /* The item's number, if type == cJSON_Number */
    /* Deprecated: use value_double instead. */
    double valuedouble;

    double *value_double;

    /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
    char *string;
} cJSON;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions