Software Development, Web Design, Training


ColdFusion Summit Notes: Geek Out With the Smart Language Additions in ColdFusion 2018, Rakshith Naresh

null support
datatype preservation

interacts w/ JavaScript, database,
how do we handle nulls in OTHER platforms?
so now we have REAL null support
and real datatype is preserved
if it’s a ‘string’ it will continue to be a bool in CF2018

null —
null in JavaScript
that came into CF
CF treats it as “undefined”
it doesn’t exists
that’s not true here
it’s not undefined anymore, it’s “null”

same w/ database nulls
null becomes “”
when you try to put empty string back into db, it’s not “Null” anymore
so your queries get wonky
where ‘’ or where null
this is fixed.

in Application.CFC:
this.enablenullsupport = true

datatype preservation
CF is a typeless lang
run CFML code in the browser!
can also SWITCH versions!

employee[“smoke”] = “no”
results in WriteOutput( smoke ) is “false”
— cf 2016

on cf 2018 it will say “no”
data type is preserved

no more hacks for null support or datatype conversion

new object oriented constructs
default functions in interface


typed arrays in 2018
negative index and slicing

Typed Array
numericArray = ArrayNew[ “numeric” ](1);
numericArray.append( “foo” ); — this will error out
(new member function instead of ArrayAppend, new inCF11)

(does ‘null’ work in the numeric array?)

arrayNew[“some CFC name”](1)
— works on CFCs
Maybe combine this with the loops over abstract or interface things?

negative index
starts from the END of the array
array[ -1 ] - gets last element
array[ -2 ] - gets second to last, etc.
sort of shortcuts for “arrayLen() - 1” tricks

array slicing
slice the arrays in CF 2018
arr = array w/ 100 elements
arr1 = arr[1:50] - first 50 things in array are now in “arr1”
arr2 = arr[51:100] - second 50 things are in arr2

arr3 = array[2:50:2]
— items 2 thru 50, step by 2
so items 2, 4, 6, 8 up to item 50
25 elements in the array

coming in a future update -
array functions - pop, push, shift, unshift, splice

query functions - updated querynew, queryappend, queryprpepend, queryrowswap, queryslice, queryclear

some/every — array, struct, query


optional semicolons