পৃষ্ঠাসমূহ

Search Your Article

CS

Pageviews

Monday, January 30, 2017

D - Functions

Basic function definition

return_type function_name( parameter list )
{
   body of the function
}
A basic function definition consists of a function header and a function body. Here are all the parts of a function:

D - Characters

Characters are the building blocks of strings. Any symbol of a writing system is called a character: letters of alphabets, numerals, punctuation marks, the space character, etc. Confusingly, the building blocks of characters themselves are called characters as well.

D - Strings

D provides following two types of string representations:
  • Character array.
  • Core Language String.

D - Arrays

D programming language provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.

D - Associative Arrays

Associative arrays have an index that is not necessarily an integer, and can be sparsely populated. The index for an associative array is called the key, and its type is called the KeyType.
Associative arrays are declared by placing the KeyType within the [ ] of an array declaration. A simple example for associative array is shown below.

D - Pointers

D programming pointers are easy and fun to learn. Some D programming tasks are performed more easily with pointers, and other D programming tasks, such as dynamic memory allocation, cannot be performed without them. A simple pointer is shown below.

D - Tuples

Tuples are used for combining multiple values as a single object. Tuples contains a sequence of elements. The elements can be types, expressions, or aliases. The number and elements of a tuple are fixed at compile time and they cannot be changed at run time.

D - Structs

D arrays allow you to define type of variables that can hold several data items of the same kind but structure is another user defined data type available in D programming, which allows you to combine data items of different kinds.

D - Unions

A union is a special data type available in D that enables you to store different data types in the same memory location. You can define a union with many members, but only one member can contain a value at any given time. Unions provide an efficient way of using the same memory location for multi-purpose.

D - Ranges

Ranges are an abstraction of element access. This abstraction enables the use of great number of algorithms over great number of container types. Ranges emphasize how container elements are accessed, as opposed to how the containers are implemented. Ranges are a very simple concept that is based on whether a type defines certain sets of member functions.

D - Aliases

Alias, as the name refers provides an alternate name for existing names. The syntax for alias is shown below.
alias new_name = existing_name;
The following is the older syntax, just in case you refer some older format examples. Its is strongly discouraged the use of this.

D - Mixins

Mixins are structs that allows mixing the generated code into the source code. Mixins can be of the following types.
  • String Mixins
  • Template Mixins
  • Mixin name spaces