AnyLang Programming Language Comparison/Anylang Common Concepts

From Wikibooks, open books for an open world
Jump to: navigation, search

AnyLang Common Concepts[edit]

The following is the central list of AnyLang Common Concepts. These are programming concepts that are common enough to be compared and applied across multiple mainstream programming languages.

code blocks

block.case_if conditional case statement
block.catch catch block
block.die how to terminate a process with error message
block.else else statement
block.else_if elseif statement
block.finally finally block
block.if if statement
block.pause how to pause the process
block.qmark_if ternary qmark question mark conditional if statement
block.quit how to terminate a process
block.switch switch statement
block.try try block
block.try_catch a simple try-catch block

code comments

codecmmt.beginend a generic begin-end multiline comment region
codecmmt.docgen docgen tag
codecmmt.multi multi-line cmmt
codecmmt.single single-line cmmt
codecmmt.xregion my_generic_region tag

debugging operatinos

codedebug.log logging errors and program info to a log file
codedebug.test if statement used for debugging or example

basic structural elements of code

codeelem.block bare code block
codeelem.end_code end code
codeelem.init_code init code
codeelem.init_lib init library
codeelem.init_vars init vars
codeelem.line_contin line continuation for putting a newline in the middle of a statement (language dependent)
codeelem.line_termin line termination character (e.g. semicolon) for langages that require it
codeelem.named_block named code block
codeelem.new_doc a new document
codeelem.new_footer a new footer within a document page
codeelem.new_header a new header within a document page
codeelem.new_lib a new document as a library module (arbitrary defn of what constitutes a module)
codeelem.new_page a new page within a document (arbitrary defn of what constitutes a page)
codeelem.new_rec a new record entry

looping structures

codeloop.arr loop over an array
codeloop.dic enumerate or iterate over a the keys and values in a dictt
codeloop.dir loop over items in a directory
codeloop.foreach for bar in foo
codeloop.whilevar while loop with a variable
codeloop.forvar old c-style loop( for icc=0; icc ~ foo.length; icc++ )
codeloop.last loop control final iteration
codeloop.modify_in_place loop over an array (or iterable) and modify the elements in place loop control, skip to the next iteration
codeloop.rows loop over rows in a SimpleTable
codeloop.while while statement


codemeta.args command line arguments passed into current script
codemeta.current_os get the current operating system that we are running under
codemeta.docs_class self-documenting class
codemeta.docs_func self-documenting functions
codemeta.docs_funcparam self-documenting function parameters
codemeta.docs_meth self-documenting methods
codemeta.docs_methname return the name of the currently running method
codemeta.docs_methparam self-documenting method parameters
codemeta.nameismain determine if source file is the current 'main' namespace [websearch://"python main trick"]
codemeta.newdoc a starting template for a new file in this language
codemeta.quick_docs help facility for language constructs
codemeta.source_line the current line in the current source file
codemeta.source_path the full path of the current source file

currently running script path

codemeta.source_pdir the parent directory of the current source file. use path of the source file itself, and NOT the path of the file that calls it via *include* or *require*
codemeta.version the language version of the current script or language interpreter

source code regions

coderegion.details worksheet of an xregion metadata island
coderegion.file_info file info metadata island
coderegion.generator worksheet of an xregion metadata island
coderegion.main worksheet of an xregion metadata island
coderegion.see_also worksheet of an xregion metadata island

console operations

console.print print to console
console.printf formatted print to console
console.println print to console with newline

data definitions and schemas

datadef.aoh just like perldsc AoH
datadef.1yamlrec small yaml syntax
datadef.2yamlrec med yaml syntax
datadef.3yamlrec big yaml syntax
datadef.newtable a new ReallySimpleData table
datadef.newwkbk a new ReallySimpleData wkbk
datadef.newwksheet a new ReallySimpleData wksheet
datadef.nvp SimpleNameValuePair
datadef.simplerec SimpleRecord
datadef.simpletable create a SimpleTable structure similar to perl AoH
datadef.simpletable_iv create a SimpleTable structure similar to perl AoA (IV = IndexedValues)
datadef.yamlrec SimpleRecord yaml syntax

data processing operations

datamunge.json_munge dump a variable out to json and load it back in from json
datamunge.dec_base_64 decode base64 format
datamunge.dec_htmlent decode HTMLEnt format
datamunge.dec_jscript decode jscript_url_style escaping
datamunge.dec_rot_13 decode rot13 format
datamunge.enc_base_64 encode base64 format
datamunge.enc_htmlent encode HTMLEnt format
datamunge.enc_jscript encode jscript_url_style escaping
datamunge.enc_rot_13 encode rot13 format

date and time operations

datetime.2date_fmt specify a string like "Fri Sep 9 13.46.58 2005" (perl localtime() in scalar context) current system Date of the Month
datetime.datem specify a string like Fri 2005-08-26 13.23.03 (preferred)
datetime.day_of_week current system Day of the week
datetime.month current system Month current system time and date
datetime.time_millisec return the current time with millisecond accuracy (for timestamps)
datetime.year current system Year

error trapping and exceptions

error.arr_bounds array index out of range
error.dict_keyex dictionary key does not exist
error.warnings enable or disable warnings

filesystem operations

filesys.basename get file basename from path
filesys.copy Copy a file or directory
filesys.delete Delete a file or directory
filesys.deltree delete a directory tree
filesys.dir_exists true if a directory exists
filesys.exten get file extension from full path
filesys.file_exists true if a file exists
filesys.file_size return file size as an integer (usu in bytes)
filesys.loop_dir loop over files within a directory
filesys.loop_tree recursively iterate files within a directory tree
filesys.mkpath create directory even if there is more than one missing pathstep
filesys.move Move a file or directory
filesys.parent_dir get file parent dir from a full path
filesys.rename Rename a file or directory

function arguments

funcarg.arg_array specify an array that holds multiple args
funcarg.arr array declare a function argument boolean declare a function argument
funcarg.defval specify function parameters argument default value integer declare a function argument
funcarg.obj object declare a function argument
funcarg.opt_arg specify an optional parameter
funcarg.passfunc pass a function as an argument
funcarg.passobj pass an object or dictionary that holds multiple args
funcarg.req_arg specify a required parameter
funcarg.str string declare a function argument

function definitions

funcdef.1func sml syntax declare a function
funcdef.1meth sml syntax declare a oop_method
funcdef.2func med syntax declare a function
funcdef.2meth med syntax declare a oop_method
funcdef.3func big syntax declare a function
funcdef.3meth big syntax declare a oop_method
funcdef.closure function as full-fledged closure
funcdef.funcdef psu funcdef template
funcdef.funcdsp function DspTemplate
funcdef.funcmeta attach arbitrary metadata to a function
funcdef.lambda function as python-lambda-style expression

basic GUI display

guidsp.alert GuiAlert(sPrompt) alert box with ok button
guidsp.button generic pushbutton control
guidsp.checkbox generic checkbox control same as html//inputCheckbox
guidsp.combo_box same as html//Select execept user can also supply a value
guidsp.date_time A box that looks like a single-line edit control but instead accepts a date and/or time. A drop-down calendar is also provided
guidsp.edit same as html//textarea
guidsp.grid grid and list control
guidsp.group_box A rectangular border/frame
guidsp.hotkey A box that looks like a single-line edit control but instead accepts a keyboard combination pressed by the user
guidsp.input_box strVal = GuiInput(sPrompt
guidsp.month_cal A relatively tall control that displays all the days of the month in calendar format
guidsp.pass simple input box for password same as html//inputPassword
guidsp.picture an area containing a picture
guidsp.progress progress bar generic radio button same as html//inputRadio
guidsp.range up-down arrows to toggle through a range of integers
guidsp.rich_edit rich edit textbox with formatting same as html//Select
guidsp.select_multi same as html//Select with multiple='true'
guidsp.slider A sliding bar that the user can move along a vertical or horizontal track control containing multiple pages
guidsp.text simple input box for text same as html//inputText

GUI windows center a window relative to the desktop (or parent window)
guiwin.coords specify the position of a window relative to the desktop (or parent window)


interop.alt_interop different alternatives for interop
interop.com_object how to instantiante a msft OLE COM object
interop.shell_run run an external program e.g. ShellRun('notepad.exe') as a separate process
interop.shell_runwait run external program and wait for it to finish

code libraries and addons

lib.include_lib include a library file
lib.include_once include a library file once

OOP classes

oopclass.class_constructor constructor method of a class
oopclass.new_class a new OOP class
oopclass.reflect_classname get the name of a class from within the class itself

OOP methods

oopmeth.alias create an alias name for an oop method
oopmeth.filter iterate through the names of all selected methods of a class based on any criteria
oopmeth.instance declare an instance method in a class
oopmeth.invokeoperator the symbol used as the method invocation operator
oopmeth.multilevel declare and use a nested method (e.g., mymap.delaware.dover.getpopulation() )
oopmeth.reflect iterate through the names of all methods of a class
oopmeth.static declare a static method in a class
oopmeth.symbolic call an oop method using a scalar for the methodname

OOP objects

oopobj.new_instance A new OOP plain object. Create an object (aka instance of a class).

OOP references

oopref.symbolic instantiate an object from an oop class using a scalar for the classname (without using string eval)

regular expressions and related concepts

regex.22_notation specify notation for individual characters char
regex.backref RegEx memorizing capture register inside match-region or substitute-region
regex.basic_syntax RegEx basic syntax basic_ops
regex.capture specify a capturing match register
regex.match RegEx match operation
regex.noncapture specify a non-capturing grouping match register
regex.replace RegEx replace operation

SQL and related concepts

sqldata.bulk_insert populate a sql table using a text file as the raw data

formatting and using strings in source code

strdsp.esc_bs1 note regex22 is better
strdsp.esc_bs2 note regex22 is better
strdsp.esc_qq1 note regex22 is better
strdsp.esc_qq2 note regex22 is better
strdsp.here_doc specify multi-line string inside code like a perl heredoc
strdsp.here_func heredoc function
strdsp.here_str string in variable
strdsp.here_var interpolated variable inside string
strdsp.heredoc_indent heredoc indented along with the rest of the code
strdsp.interpo specify a string variable with possible interpolation
strdsp.number_format pretty-format a number for locale or data display
strdsp.printf specify a string variable with special formatting options
strdsp.skeleton_fill fill in the content of a SimpleTemplate
strdsp.verbatim specify a string variable with NO interpolation

reserved for later use

system.timeout throw an exception or terminate process if it is taking too long


template.delim specify the syntax for template delimiter
template.valueof value output for template style programming

data validation

valid.file_exist true if a file exists in the filesystem
valid.file_not_exist true if a file does not exist in the filesystem
valid.is_numeric expression evaluates to a number
valid.is_string expression evaluates to a string
valid.is_true expression evaluates to truth value

variable declaration

vardec.myarr quickly declare array
vardec.myboo quickly declare boolean
vardec.mydic quickly declare dictionary
vardec.myint quickly declare integer
vardec.myobj quickly declare object
vardec.mystr quickly declare string
vardec.null represent a null value in source

working with variables

varops.array_assign assign a value to Array
varops.array_decl declare Array
varops.array_init initialize Array
varops.composite_defn define a composite variable (e.g., like with perl data structure cookbook)
varops.composite_manip manipulate a composite variable (e.g. sort, search filter view add edit delete)
varops.dumper dump variable contents like with perl DataDumper
varops.object_assign assign a value to Object
varops.object_decl declare Object
varops.object_dupe_byref shallow copy and duplicate an object or nested variable by reference
varops.object_dupe_byval copy and duplicate an object or nested variable by value
varops.object_init initialize Object
varops.scalar_assign assign a value to a scalar
varops.scalar_decl declare a scalar
varops.scalar_init initialize a scalar
varops.typecast convert the native type of a variable into another type
varops.vartype get the native type of a variable

web and http

webhttp.htinclude transclusion include one page or page fragment into another
webhttp.cflocation redirect to a new page like coldfusion cflocation
webhttp.cgi_referrer client referrer url
webhttp.cgi_remoteaddr client IP address
webhttp.server_get grab a web page from another site using serverside code