1 // just docs: Differences
2 /++
3 $(H1 Differences from GDScript)
4 
5 $(TABLE
6 	$(CLASS small-table)
7 	$(TR $(TH ) $(TH GDScript) $(TH D))
8 	
9 	$(TR $(TD $(B Variables)))
10 	$(TR $(TD Instantiation:) $(TD `var n = Node.new()`) $(TD $(D auto n = memnew!Node;)))
11 	$(TR $(TD Deletion:) $(TD `n.free()`) $(TD $(D memdelete(n);)))
12 	$(TR $(TD Reference-counting:) $(TD All vars inheriting Reference are automatically ref-counted) $(TD $(D Ref!ArrayMesh rc = memnew!ArrayMesh; // explicit Ref!T wrapper increments ref-count)))
13 	$(TR $(TD Dynamic typing:) $(TD All vars are dynamically-typed) $(TD $(D Variant v; // accepts any Godot-compatible type)))
14 	$(TR $(TD Checking inheritance:) $(TD `if n is Node2D:`) $(TD $(D if(n.as!Node2D) // null if n doesn't inherit Node2D)))
15 	
16 	$(TR $(TD $(B Scripts)))
17 	$(TR $(TD Inheritance:) $(TD `class MyNode extends Node:`) $(TD $(D class MyNode : GodotScript!Node { })))
18 	$(TR $(TD Export method:) $(TD `func _ready(): # automatically exported`) $(TD $(D @Method void _ready() { })))
19 	$(TR $(TD Export property:) $(TD `export var text = "asdf"`) $(TD $(D @Property String text = gs!"asdf";)))
20 	$(TR $(TD Global variables:) $(TD $(LINK2 https://godot.readthedocs.io/en/latest/getting_started/step_by_step/singletons_autoload.html, Autoloaded singleton nodes) only) $(TD Autoloaded singleton nodes; alternatively, D variables declared outside any class, or as $(D static) inside a class))
21 	
22 	$(TR $(TD $(B Naming conventions)))
23 	$(TR $(TD Class/node:) $(TD PascalCase) $(TD PascalCase))
24 	$(TR $(TD Function/variable:) $(TD snake_case) $(TD camelCase))
25 	$(TR $(TD Constant/enum:) $(TD ALL_CAPS) $(TD camelCase))
26 	
27 	$(TR $(TD $(B Math)) $(TD $(B in $(LINK2 https://godot.readthedocs.io/en/latest/classes/class_@gdscript.html, global scope))) $(TD $(B in $(MREF std, math))))
28 	$(TR $(TD ) $(TD abs) $(TD ))
29 	$(TR $(TD ) $(TD acos) $(TD ))
30 	$(TR $(TD ) $(TD asin) $(TD ))
31 	$(TR $(TD ) $(TD atan) $(TD ))
32 	$(TR $(TD ) $(TD atan2) $(TD ))
33 	$(TR $(TD ) $(TD ceil) $(TD ))
34 	$(TR $(TD ) $(TD cos) $(TD ))
35 	$(TR $(TD ) $(TD cosh) $(TD ))
36 	$(TR $(TD ) $(TD deg2rad) $(TD $(D x*(PI/180))))
37 	$(TR $(TD ) $(TD exp) $(TD ))
38 	$(TR $(TD ) $(TD floor) $(TD ))
39 	$(TR $(TD ) $(TD fmod) $(TD ))
40 	$(TR $(TD ) $(TD is_inf) $(TD $(D isInfinity)))
41 	$(TR $(TD ) $(TD is_nan) $(TD $(D isNaN)))
42 	$(TR $(TD ) $(TD log) $(TD ))
43 	$(TR $(TD ) $(TD nearest_po2) $(TD $(D x.isPowerOf2 ? x : x.nextPow2)))
44 	$(TR $(TD ) $(TD PI) $(TD ))
45 	$(TR $(TD ) $(TD pow) $(TD ))
46 	$(TR $(TD ) $(TD rad2deg) $(TD $(D x*(180/PI))))
47 	$(TR $(TD ) $(TD round) $(TD ))
48 	$(TR $(TD ) $(TD sign) $(TD $(D sgn)))
49 	$(TR $(TD ) $(TD sin) $(TD ))
50 	$(TR $(TD ) $(TD sinh) $(TD ))
51 	$(TR $(TD ) $(TD sqrt) $(TD ))
52 	$(TR $(TD ) $(TD tan) $(TD ))
53 	$(TR $(TD ) $(TD tanh) $(TD ))
54 	
55 	$(TR $(TD $(B Algorithms)) $(TD $(B in $(LINK2 https://godot.readthedocs.io/en/latest/classes/class_@gdscript.html, global scope))) $(TD $(B in $(MREF std, algorithm))))
56 	$(TR $(TD ) $(TD clamp) $(TD ))
57 	$(TR $(TD ) $(TD max) $(TD ))
58 	$(TR $(TD ) $(TD min) $(TD ))
59 	
60 	$(TR $(TD $(B Other functions)) $(TD $(B in $(LINK2 https://godot.readthedocs.io/en/latest/classes/class_@gdscript.html, global scope))) $(TD ))
61 	$(TR $(TD ) $(TD assert) $(TD $(D assert) keyword))
62 	$(TR $(TD ) $(TD load) $(TD $(D ResourceLoader.load)))
63 	$(TR $(TD ) $(TD preload) $(TD not usable from D))
64 	$(TR $(TD ) $(TD print) $(TD $(REF print, godot, d, output)))
65 	
66 	$(TR $(TD $(B Constants and enums)) $(TD $(B Globals in $(LINK2 https://godot.readthedocs.io/en/latest/classes/class_@globalscope.html, global scope))) $(TD $(B in $(MREF godot, globalconstants))))
67 	$(TR $(TD Class constants:) $(TD `Material.RENDER_PRIORITY_MAX`) $(TD $(D Material.Constants.renderPriorityMax)))
68 )
69 
70 +/
71 module godot.docs.differences;