Repository navigation
Partial
Home › Partial Types › Partial
Writes one type or class in several blocks of one compilation unit.
[ public | private ] partial type name [ extends base ] [ field = n ]
member declarations
end type
[ public | private ] partial class name
[ inherits base ]
[ implements interface [ , interface ... ] ]
member declarations
end classEach block is a part. The compiler combines the parts into one type before anything else reads them, so the rest of the program sees an ordinary type.
The parts must be in one source file with its includes, or in the files of one module, at module or namespace level and in the same namespace. Every block of the type says partial, and all of them are type or all of them are class.
Fields are laid out part by part. A module's files are read in sorted order of their names, so the file whose name sorts first supplies the first fields. A base type's fields always come first, whichever part names the base.
extends, inherits, field, extern layout and implements may each appear on one part, and apply to the whole type. public on any part makes the type public; public on one part and private on another is an error.
A part can hold methods alone, as long as the whole type has a field. A generic type cannot be partial.
partial is a keyword only directly before type or class. It remains an ordinary name everywhere else.
partial type Point
x as long
y as long
end type
partial type Point
declare function Sum( ) as long
end type
function Point.Sum( ) as long
return x + y
end function
dim as Point p = type( 3, 4 )
print p.Sum( ) ' 7A class whose base is named by its second part:
class Vehicle
Wheels as long = 4
end class
partial class Car
Doors as long = 2
end class
partial class Car
inherits Vehicle
declare function Total( ) as long
end class
function Car.Total( ) as long
return Wheels + Doors
end function
dim as Car c
print c.Total( ) ' 6tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing