F# Training
Formation F#
Formation F#
  • Intro
  • Bases
    • Le F♯, c'est quoi ?
    • Syntaxe
    • Premiers concepts
    • 🍔 Quiz
  • Fonctions
    • Signature
    • Fonctions
    • Fonctions standard
    • OpĂ©rateurs
    • Fonctions : complĂ©ments
    • 🍔 Quiz
    • 📜 RĂ©cap’
  • Types composites
    • GĂ©nĂ©ralitĂ©s
    • Tuples
    • Records
    • Unions
    • Enums
    • Records anonymes
    • Types valeur
    • 🍔 Quiz
  • Types : ComplĂ©ments
    • Type unit
    • GĂ©nĂ©riques
    • Types flexibles
    • UnitĂ©s de mesure
    • Conversion
    • Exceptions F#
  • Pattern matching
    • Patterns
    • Match expression
    • 🚀 Active Patterns
    • 📜 RĂ©cap’
  • Collections
    • Vue d'ensemble
    • Types
    • Fonctions gĂ©nĂ©riques
    • Fonctions spĂ©cifiques
    • 🍔 Quiz
    • 📜 RĂ©cap’
  • Programmation asynchrone
    • Workflow asynchrone
    • Interop avec la TPL .NET
    • 📜 RĂ©cap’
  • Types monadiques
    • Type Option
    • Type Result
    • Smart constructor
    • 🚀 Computation expression (CE)
    • 🚀 CE - Fondements thĂ©oriques
    • 📜 RĂ©cap’
  • Module & namespace
    • Vue d'ensemble
    • Namespace
    • Module
    • 🍔 Quiz
    • 📜 RĂ©cap’
  • OrientĂ©-objet
    • Introduction
    • Membres
    • Extensions de type
    • Classe, structure
    • Interface
    • Expression objet
    • Recommandations
  • 🦚 Aller plus loin
Powered by GitBook
On this page
  • Type composite struct
  • Attribut [<Struct>]
  • Mot clĂ© struct
  • Structures

Was this helpful?

Edit on GitHub
  1. Types composites

Types valeur

Type composite struct

Un type composite peut être déclaré en tant que type valeur

  • Instances stockĂ©es dans la pile (stack) plutĂ´t que dans le tas (heap)

  • Permet parfois de gagner en performance

  • PlutĂ´t adaptĂ© aux types compacts : peu de champs, peu de comportements

Types de déclaration :

  • Attribut [<Struct>]

  • Mot clĂ© struct

  • Structure

Attribut [<Struct>]

Pour Record et Union

À placer avant ou après le mot cle type

type [<Struct>] Point = { X: float; Y: float }

[<Struct>]
type SingleCase = Case of string

Mot clé struct

Pour littéral de Tuple et Record anonyme

let t = struct (1, "a")
// struct (int * string)

let a = struct {| Id = 1; Value = "a" |}
// struct {| Id: int; Value: string |}

Structures

👉 Cf. session sur l'orienté-objet et les classes...

PreviousRecords anonymesNext🍔 Quiz

Last updated 3 years ago

Was this helpful?

Alternatives aux classes 📍 mais + limités / héritage et récursivité

Classe