D programming language is an object oriented multi-paradigm system
programming language developed by Walter Bright of Digital Mars. It's
development started in 1999 and was first released in 2001. The major
version of D(1.0) was released in 2007. Currently, we have D2 version of
D.
পৃষ্ঠাসমূহ
Labels
Search Your Article
CS
Pageviews
Showing posts with label D Programming Basics. Show all posts
Showing posts with label D Programming Basics. Show all posts
Monday, January 30, 2017
D - Environment
Try it Option Online
You really do not need to set up your own environment to start learning D programming language. Reason is very simple, we already have set up D Programming environment online, so that you can build and execute all the available examples online at the same time when you are doing your theory work.
D - Basic Syntax
D is quite simple to learn and lets start creating our first D program!
First D Program
Let us write a simple D program. All D files will have extension .d. So put the following source code in a test.d file.import std.stdio;
D - Variables
A variable is nothing but a name given to a storage area that our
programs can manipulate. Each variable in D has a specific type, which
determines the size and layout of the variable's memory; the range of
values that can be stored within that memory; and the set of operations
that can be applied to the variable.
D - Data Types
In the D programming language, data types refer to an extensive
system used for declaring variables or functions of different types. The
type of a variable determines how much space it occupies in storage and
how the bit pattern stored is interpreted.
D - Enums
An enumeration is used for defining named constant values. An enumerated type is declared using the enum keyword.
The enum syntax
The simplest form of an enum definition is the following:enum enum_name { enumeration list }Where,
D - Literals
Constant values that are typed in the program as a part of the source code are called literals.
Literals can be of any of the basic data types and can be divided into Integer Numerals, Floating-Point Numerals, Characters, Strings and Boolean Values.
Literals can be of any of the basic data types and can be divided into Integer Numerals, Floating-Point Numerals, Characters, Strings and Boolean Values.
D - Operators
An operator is a symbol that tells the compiler to perform specific
mathematical or logical manipulations. D language is rich in built-in
operators and provides the following types of operators:
D - Loops
There may be a situation, when you need to execute a block of code
several number of times. In general, statements are executed
sequentially: The first statement in a function is executed first,
followed by the second, and so on.
D - Decisions
Decision making structures require that the programmer specify one or
more conditions to be evaluated or tested by the program, along with a
statement or statements to be executed if the condition is determined to
be true, and optionally, other statements to be executed if the
condition is determined to be false.
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.
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.
Subscribe to:
Posts (Atom)