Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The opposite of scalar variables

Tags:

c

php

terminology

PHP and C use the term "scalar variables".

Scalar variables are those containing an integer, float, string or boolean. Types array, object and resource are not scalar.

Is there a term that describes the variables that are not scalar?

like image 266
Emanuil Rusev Avatar asked Dec 26 '14 22:12

Emanuil Rusev


2 Answers

In terms of the data-type (for PHP, not C):

Most often a scalar type represents a primitive data type. Next, to that, you have composite types (arrays, objects) and other types (resource handles) (this classification of data-types is leaned on the ones from Wikipedia).

In PHP NULL is not part of the scalars.

This aligns with the groups given in the Types Introduction in the PHP Manual:

  • scalar types: boolean, integer, float, string
  • compound types: array, object
  • special types: resource, NULL

And from the PHP manual entry for the is_scalar function:

Scalar types are those containing an integer, float, string or boolean. Types array, object and resource are not scalar.

like image 66
hakre Avatar answered Sep 22 '22 14:09

hakre


In C terminology the Standard distinguishes scalar types and "aggregate and union types".

Structure and array types form the aggregate types. An union type is not of an aggregate type. Arithmetic and pointer types form the scalar types.

like image 28
ouah Avatar answered Sep 19 '22 14:09

ouah