Difference between revisions of "Visual Prolog 7.2 New Features"

From wiki.visual-prolog.com

(Header level)
Line 2: Line 2:
Following are the most significant changes.
Following are the most significant changes.


=Language Features=
== Language Features ==


Visual Prolog 7.2 brings several language improvements. This section gives a brief overview of some of them.
Visual Prolog 7.2 brings several language improvements. This section gives a brief overview of some of them.


==Anonymous predicates==
=== Anonymous predicates ===


Anonymous predicates are the Prolog counterparts to anonymous functions as known in functional programming languages. Anonymous predicates are described in details in the article ''[http://wiki.visual-prolog.com/index.php?title=Language_Reference/Terms/Anonymous_Predicates Anonymous Predicates]'' of Visual Prolog Language Reference.
Anonymous predicates are the Prolog counterparts to anonymous functions as known in functional programming languages. Anonymous predicates are described in details in the article ''[http://wiki.visual-prolog.com/index.php?title=Language_Reference/Terms/Anonymous_Predicates Anonymous Predicates]'' of Visual Prolog Language Reference.


==64 bit numbers==
=== 64 bit numbers ===


''' integer64''' and '''unsigned64''' are two new built-in types, that replace the PFC domains '''core::integer64''' and '''core::unsigned64'''. The new domains are like integer and unsigned expect that they have a 64-bit representation. All arithmetic operations (except the power operation) are supported for the types. They are written, read, saved and consulted in normal number format only with much larger range than 32-bit numbers. PFC has been updated to use '''integer64''' and '''unsigned64''' instead of '''core::integer64''' and '''core::unsigned64'''. So now (as example) file positions are '''unsigned64'''. The same is the case with '''gmtTimeValue''', '''localTimeValue''' and '''timeIntervalValue'''.
''' integer64''' and '''unsigned64''' are two new built-in types, that replace the PFC domains '''core::integer64''' and '''core::unsigned64'''. The new domains are like integer and unsigned expect that they have a 64-bit representation. All arithmetic operations (except the power operation) are supported for the types. They are written, read, saved and consulted in normal number format only with much larger range than 32-bit numbers. PFC has been updated to use '''integer64''' and '''unsigned64''' instead of '''core::integer64''' and '''core::unsigned64'''. So now (as example) file positions are '''unsigned64'''. The same is the case with '''gmtTimeValue''', '''localTimeValue''' and '''timeIntervalValue'''.


==Namespaces==
=== Namespaces ===


Interfaces and classes can be put into name-spaces (like '''pfc\pie'''). This allows the same interface/class name to be declared/defined in several name spaces in the same program. So now it is possible (as example) to have a class called '''file ''' in the namespace '''documentManager''' even though there is also a class named '''file''' in PFC. It is planned (but not effectuated at the time of writing) to put PFC classes in namespaces '''pfc''', '''pfc\vip5x '''and''' pfc\gui'''. Also the new '''pie''' packages (described below) are in the name space ''' pfc\pie'''.
Interfaces and classes can be put into name-spaces (like '''pfc\pie'''). This allows the same interface/class name to be declared/defined in several name spaces in the same program. So now it is possible (as example) to have a class called '''file ''' in the namespace '''documentManager''' even though there is also a class named '''file''' in PFC. It is planned (but not effectuated at the time of writing) to put PFC classes in namespaces '''pfc''', '''pfc\vip5x '''and''' pfc\gui'''. Also the new '''pie''' packages (described below) are in the name space ''' pfc\pie'''.


==binaryNonAtomic domain==
=== binaryNonAtomic domain ===


A new built-in domain '''binaryNonAtomic''' is introduced to distinguish binaries may contain pointers and should therefore be scanned by the garbage collector. The ordinary '''binary''' domain is no longer scanned for pointers.
A new built-in domain '''binaryNonAtomic''' is introduced to distinguish binaries may contain pointers and should therefore be scanned by the garbage collector. The ordinary '''binary''' domain is no longer scanned for pointers.


==real32==
=== real32 ===


A domain ''' real32''' is introduced to ease the integration with foreign API's that sometimes uses such short reals. It is not intended for use in "normal" code.
A domain ''' real32''' is introduced to ease the integration with foreign API's that sometimes uses such short reals. It is not intended for use in "normal" code.


=Compiler=
== Compiler ==


The compiler is (obviously) updated to deal with the new language features. But it has also been improved in several other respects.
The compiler is (obviously) updated to deal with the new language features. But it has also been improved in several other respects.


==Unreachable code detection==
=== Unreachable code detection ===


The ability to detect unreachable code has been improved vastly, both when it comes to detecting unused predicates and facts and when it comes to code inside clauses which cannot be reached. Unreachable code will cause warnings.
The ability to detect unreachable code has been improved vastly, both when it comes to detecting unused predicates and facts and when it comes to code inside clauses which cannot be reached. Unreachable code will cause warnings.


==Superfluous test detection==
=== Superfluous test detection ===


The compiler will also give warnings about tests, which are trivially fulfilled due to the type of the involved variables. Consider this code for example:
The compiler will also give warnings about tests, which are trivially fulfilled due to the type of the involved variables. Consider this code for example:
Line 64: Line 64:
If X  -  23 gives a negative number, the '''tryConvert''' will fail.
If X  -  23 gives a negative number, the '''tryConvert''' will fail.


==Smaller code==
=== Smaller code ===


The size of the generated code has become smaller, especially for predicates with many clauses that match different patterns of input.
The size of the generated code has become smaller, especially for predicates with many clauses that match different patterns of input.


==Less stack usage==
=== Less stack usage ===


Likewise, the stack size has been reduced (dramatically in some cases).
Likewise, the stack size has been reduced (dramatically in some cases).


=IDE=
== IDE ==


Many bugs and inconveniences have been solved in the IDE. Just like numerous smaller and larger improvements has been made. This section describes some of the major improvements.
Many bugs and inconveniences have been solved in the IDE. Just like numerous smaller and larger improvements has been made. This section describes some of the major improvements.


==Build speed==
=== Build speed ===


The build system has been changed such that it can utilize multi-core processors by compiling several packages in parallel. On a quad-core processor this typically gives a factor 4 (sometimes more) when many packages needs to be compiled.
The build system has been changed such that it can utilize multi-core processors by compiling several packages in parallel. On a quad-core processor this typically gives a factor 4 (sometimes more) when many packages needs to be compiled.
Line 84: Line 84:
This feature has given a factor 4 when rebuilding a ''very'' large project.
This feature has given a factor 4 when rebuilding a ''very'' large project.


==IntelliSence==
=== IntelliSence ===


Browse information (i.e. information about the source code fed from the compiler back to the IDE) is now utilized to provide IntelliSense: When you edit source code the IDE shows possible/sensible completion of the word you are typing. You can then select the completion in the list using mouse, arrow keys and TAB; the IDE will complete the word with your choice. The IDE will also show tool tip windows showing the declaration of the predicate you are about to write arguments for. That way you can see which arguments the predicate takes without changing context.
Browse information (i.e. information about the source code fed from the compiler back to the IDE) is now utilized to provide IntelliSense: When you edit source code the IDE shows possible/sensible completion of the word you are typing. You can then select the completion in the list using mouse, arrow keys and TAB; the IDE will complete the word with your choice. The IDE will also show tool tip windows showing the declaration of the predicate you are about to write arguments for. That way you can see which arguments the predicate takes without changing context.


==Window Navigation Dialog==
=== Window Navigation Dialog ===


The order, in which Ctrl-TAB shifts between IDE windows, has been changed to visit most-recently-visited windows first.
The order, in which Ctrl-TAB shifts between IDE windows, has been changed to visit most-recently-visited windows first.
Line 96: Line 96:
windows starting with the letters you have pressed.
windows starting with the letters you have pressed.


==Grouping editor windows==
=== Grouping editor windows ===


Editor windows can be grouped together to look and behave like a single window. This has the advantage that you can arrange windows in a fixed layout inside the IDE. The IDE will remember two different layouts, one for "normal" mode and one for debug mode. Typically, you want large editor windows in "normal" mode, but smaller editors in debug mode to give more room for the variables window, etc.
Editor windows can be grouped together to look and behave like a single window. This has the advantage that you can arrange windows in a fixed layout inside the IDE. The IDE will remember two different layouts, one for "normal" mode and one for debug mode. Typically, you want large editor windows in "normal" mode, but smaller editors in debug mode to give more room for the variables window, etc.


==Resources view in project tree==
=== Resources view in project tree ===


When selecting a resource (e.g. a dialog or a bitmap) in the project tree, the right pane will show a preview of the resource.
When selecting a resource (e.g. a dialog or a bitmap) in the project tree, the right pane will show a preview of the resource.


==Zooming==
=== Zooming ===


Pressing the Ctrl and using the mouse wheel the IDE will increase/decrease font size in various windows creating a zoom effect. Zooming is also bound to Ctrl-+, Ctrl--, and Ctrl-0 reset to 100%.
Pressing the Ctrl and using the mouse wheel the IDE will increase/decrease font size in various windows creating a zoom effect. Zooming is also bound to Ctrl-+, Ctrl--, and Ctrl-0 reset to 100%.


==Un-/commenting blocks==
=== Un-/commenting blocks ===


The editor has new commands for commenting and un-commenting a block of code with %-chars. The commands are bound to Ctrl-Alt-% and Ctrl-Alt-Shift-%. (It would be more correct to state the keys as Ctrl-Alt-5 and Ctrl-Alt-Shift-5, but it seems simpler to remember the %-key).
The editor has new commands for commenting and un-commenting a block of code with %-chars. The commands are bound to Ctrl-Alt-% and Ctrl-Alt-Shift-%. (It would be more correct to state the keys as Ctrl-Alt-5 and Ctrl-Alt-Shift-5, but it seems simpler to remember the %-key).


=PFC=
== PFC ==


PFC has mainly been consolidated, updated to 64-bit numbers and things like that. But there are also some new things.
PFC has mainly been consolidated, updated to 64-bit numbers and things like that. But there are also some new things.


==PIE==
=== PIE ===


The engine of PIE (Prolog Interpreter Engine) is now added to PFC and will therefore be supported as a tool in future. The most important feature is that you can easily hook-in predicates from you own application. Subsequently, the PIE programs can manipulate your application. So PIE is very useful as a scripting engine in applications. Besides this, the efficiency has been improved and PIE now supports functions and real numbers.
The engine of PIE (Prolog Interpreter Engine) is now added to PFC and will therefore be supported as a tool in future. The most important feature is that you can easily hook-in predicates from you own application. Subsequently, the PIE programs can manipulate your application. So PIE is very useful as a scripting engine in applications. Besides this, the efficiency has been improved and PIE now supports functions and real numbers.


==progressBarControl==
=== progressBarControl ===


A progressBarControl binds to the win32 common control progress bar. It is the intension to add additional win32 common controls, but to deal more easily with them certain inner parts of PFC GUI will have to be revised first.
A progressBarControl binds to the win32 common control progress bar. It is the intension to add additional win32 common controls, but to deal more easily with them certain inner parts of PFC GUI will have to be revised first.


==postAction==
=== postAction ===


A new predicate '''postAction''' on the '''window''' class, makes it possible to post an action to any window. The action will be packed in a user message and when the user message is handled the action is executed. Together with anonymous predicates this makes any other use of user messages superfluous.
A new predicate '''postAction''' on the '''window''' class, makes it possible to post an action to any window. The action will be packed in a user message and when the user message is handled the action is executed. Together with anonymous predicates this makes any other use of user messages superfluous.


==popupWindow==
=== popupWindow ===


A new class ''' popupWindow''' makes it easier to create popup windows like tooltips. Most importantly popup windows must have the screen as parent so that they can be drawn outside their logical owner and on top of other windows.
A new class ''' popupWindow''' makes it easier to create popup windows like tooltips. Most importantly popup windows must have the screen as parent so that they can be drawn outside their logical owner and on top of other windows.


==radixTree==
=== radixTree ===


A radix tree is a map from '''pointer''' to any type. Its main advantage (over for example red-black-trees) is that supports very efficient merge of several maps. The disadvantage is that the keys are pointer values, so the trees can only be used on things with unique pointers (like '''object''' and '''symbol''').
A radix tree is a map from '''pointer''' to any type. Its main advantage (over for example red-black-trees) is that supports very efficient merge of several maps. The disadvantage is that the keys are pointer values, so the trees can only be used on things with unique pointers (like '''object''' and '''symbol''').


==uxTheme native bindings==
=== uxTheme native bindings ===


Native bindings to uxTheme make it possible to experiment with creating '''''theme''''' ''' ''aware''''' controls. Theme aware controls are not drawn using lines, circles, rectangles, etc. Instead they are drawn using '''''theme elements'''''. Theme elements are logical graphical entities like divider line, button surface, button outline, drop-down mark, etc. You combine/draw such logical elements into your control, and when the theme changes your control will also change appearance. If you have chosen the elements wisely your control will also blend-in with other themes.
Native bindings to uxTheme make it possible to experiment with creating '''''theme''''' ''' ''aware''''' controls. Theme aware controls are not drawn using lines, circles, rectangles, etc. Instead they are drawn using '''''theme elements'''''. Theme elements are logical graphical entities like divider line, button surface, button outline, drop-down mark, etc. You combine/draw such logical elements into your control, and when the theme changes your control will also change appearance. If you have chosen the elements wisely your control will also blend-in with other themes.


==getFactChainLength_nd==
=== getFactChainLength_nd ===


A new predicate '''getFactChainLength_nd''' (in the '''profileMemory''' class) returns the number of facts in each class fact chain in the entire program. It is intended to help tracking down problems with class facts that are not retracted when they should and therefore eats memory by keeping data alive that should have been dead.
A new predicate '''getFactChainLength_nd''' (in the '''profileMemory''' class) returns the number of facts in each class fact chain in the entire program. It is intended to help tracking down problems with class facts that are not retracted when they should and therefore eats memory by keeping data alive that should have been dead.


==weakPointer==
=== weakPointer ===


Weak pointers are "pointers" that the garbage collector does not see as pointers, so if there are only weak pointers to a piece of memory the garbage collector will recycle that piece of memory. As a consequence, a weak pointer cannot always be dereferenced, sometimes the target as been recycled. Dereferencing of a weak pointer it therefore done using a '''determ''' predicate.
Weak pointers are "pointers" that the garbage collector does not see as pointers, so if there are only weak pointers to a piece of memory the garbage collector will recycle that piece of memory. As a consequence, a weak pointer cannot always be dereferenced, sometimes the target as been recycled. Dereferencing of a weak pointer it therefore done using a '''determ''' predicate.


So in short a weak pointer is a pointer that will not keep memory alive<font size="11.0pt">. </font>
So in short a weak pointer is a pointer that will not keep memory alive<font size="11.0pt">. </font>

Revision as of 08:32, 19 September 2008

Visual Prolog 7.2 introduces many new features and improvements. Following are the most significant changes.

Language Features

Visual Prolog 7.2 brings several language improvements. This section gives a brief overview of some of them.

Anonymous predicates

Anonymous predicates are the Prolog counterparts to anonymous functions as known in functional programming languages. Anonymous predicates are described in details in the article Anonymous Predicates of Visual Prolog Language Reference.

64 bit numbers

integer64 and unsigned64 are two new built-in types, that replace the PFC domains core::integer64 and core::unsigned64. The new domains are like integer and unsigned expect that they have a 64-bit representation. All arithmetic operations (except the power operation) are supported for the types. They are written, read, saved and consulted in normal number format only with much larger range than 32-bit numbers. PFC has been updated to use integer64 and unsigned64 instead of core::integer64 and core::unsigned64. So now (as example) file positions are unsigned64. The same is the case with gmtTimeValue, localTimeValue and timeIntervalValue.

Namespaces

Interfaces and classes can be put into name-spaces (like pfc\pie). This allows the same interface/class name to be declared/defined in several name spaces in the same program. So now it is possible (as example) to have a class called file in the namespace documentManager even though there is also a class named file in PFC. It is planned (but not effectuated at the time of writing) to put PFC classes in namespaces pfc, pfc\vip5x and pfc\gui. Also the new pie packages (described below) are in the name space pfc\pie.

binaryNonAtomic domain

A new built-in domain binaryNonAtomic is introduced to distinguish binaries may contain pointers and should therefore be scanned by the garbage collector. The ordinary binary domain is no longer scanned for pointers.

real32

A domain real32 is introduced to ease the integration with foreign API's that sometimes uses such short reals. It is not intended for use in "normal" code.

Compiler

The compiler is (obviously) updated to deal with the new language features. But it has also been improved in several other respects.

Unreachable code detection

The ability to detect unreachable code has been improved vastly, both when it comes to detecting unused predicates and facts and when it comes to code inside clauses which cannot be reached. Unreachable code will cause warnings.

Superfluous test detection

The compiler will also give warnings about tests, which are trivially fulfilled due to the type of the involved variables. Consider this code for example:

clauses
     ppp(X) :- 
         Y = X - 23, 
         Y >= ,  
        qqq(Y).

where qqq is declared like this:

predicates
      qqq : (positive V).

The code above might seem reasonable, we only want to call qqq if Y is indeed greater than or equal to zero.

The only problem is Y is always greater than zero, because Y has the type positive, which only contains numbers that are greater than or equal to zero.

If the calculation X 23 gives a negative number an out-of-range exception will be raised (before reaching the test). So this new warning can help the programmer detect places where it seems that testing ensures validity of the code, while in reality the test will never fail because an exception will be raised instead. The code above can be corrected using this code:

clauses
   ppp(X) :-
       Y = tryConvert(positive, X - 23),
       qqq(Y).

If X - 23 gives a negative number, the tryConvert will fail.

Smaller code

The size of the generated code has become smaller, especially for predicates with many clauses that match different patterns of input.

Less stack usage

Likewise, the stack size has been reduced (dramatically in some cases).

IDE

Many bugs and inconveniences have been solved in the IDE. Just like numerous smaller and larger improvements has been made. This section describes some of the major improvements.

Build speed

The build system has been changed such that it can utilize multi-core processors by compiling several packages in parallel. On a quad-core processor this typically gives a factor 4 (sometimes more) when many packages needs to be compiled.

As of this writing, we are also working on letting the compiler itself compile several packages in a single invocation and thus skip many compiler phases for files that are included in several packages.

This feature has given a factor 4 when rebuilding a very large project.

IntelliSence

Browse information (i.e. information about the source code fed from the compiler back to the IDE) is now utilized to provide IntelliSense: When you edit source code the IDE shows possible/sensible completion of the word you are typing. You can then select the completion in the list using mouse, arrow keys and TAB; the IDE will complete the word with your choice. The IDE will also show tool tip windows showing the declaration of the predicate you are about to write arguments for. That way you can see which arguments the predicate takes without changing context.

Window Navigation Dialog

The order, in which Ctrl-TAB shifts between IDE windows, has been changed to visit most-recently-visited windows first.

Furthermore, Ctrl-TAB also brings up a navigation dialog listing all the open windows. The dialog stays up as long as Ctrl-key is pressed. In this dialog you can see the windows in the order they will be shifted to, but you can also choose a window directly using the mouse or the arrow keys. If you press letters the list will be filtered to

windows starting with the letters you have pressed.

Grouping editor windows

Editor windows can be grouped together to look and behave like a single window. This has the advantage that you can arrange windows in a fixed layout inside the IDE. The IDE will remember two different layouts, one for "normal" mode and one for debug mode. Typically, you want large editor windows in "normal" mode, but smaller editors in debug mode to give more room for the variables window, etc.

Resources view in project tree

When selecting a resource (e.g. a dialog or a bitmap) in the project tree, the right pane will show a preview of the resource.

Zooming

Pressing the Ctrl and using the mouse wheel the IDE will increase/decrease font size in various windows creating a zoom effect. Zooming is also bound to Ctrl-+, Ctrl--, and Ctrl-0 reset to 100%.

Un-/commenting blocks

The editor has new commands for commenting and un-commenting a block of code with %-chars. The commands are bound to Ctrl-Alt-% and Ctrl-Alt-Shift-%. (It would be more correct to state the keys as Ctrl-Alt-5 and Ctrl-Alt-Shift-5, but it seems simpler to remember the %-key).

PFC

PFC has mainly been consolidated, updated to 64-bit numbers and things like that. But there are also some new things.

PIE

The engine of PIE (Prolog Interpreter Engine) is now added to PFC and will therefore be supported as a tool in future. The most important feature is that you can easily hook-in predicates from you own application. Subsequently, the PIE programs can manipulate your application. So PIE is very useful as a scripting engine in applications. Besides this, the efficiency has been improved and PIE now supports functions and real numbers.

progressBarControl

A progressBarControl binds to the win32 common control progress bar. It is the intension to add additional win32 common controls, but to deal more easily with them certain inner parts of PFC GUI will have to be revised first.

postAction

A new predicate postAction on the window class, makes it possible to post an action to any window. The action will be packed in a user message and when the user message is handled the action is executed. Together with anonymous predicates this makes any other use of user messages superfluous.

popupWindow

A new class popupWindow makes it easier to create popup windows like tooltips. Most importantly popup windows must have the screen as parent so that they can be drawn outside their logical owner and on top of other windows.

radixTree

A radix tree is a map from pointer to any type. Its main advantage (over for example red-black-trees) is that supports very efficient merge of several maps. The disadvantage is that the keys are pointer values, so the trees can only be used on things with unique pointers (like object and symbol).

uxTheme native bindings

Native bindings to uxTheme make it possible to experiment with creating theme aware controls. Theme aware controls are not drawn using lines, circles, rectangles, etc. Instead they are drawn using theme elements. Theme elements are logical graphical entities like divider line, button surface, button outline, drop-down mark, etc. You combine/draw such logical elements into your control, and when the theme changes your control will also change appearance. If you have chosen the elements wisely your control will also blend-in with other themes.

getFactChainLength_nd

A new predicate getFactChainLength_nd (in the profileMemory class) returns the number of facts in each class fact chain in the entire program. It is intended to help tracking down problems with class facts that are not retracted when they should and therefore eats memory by keeping data alive that should have been dead.

weakPointer

Weak pointers are "pointers" that the garbage collector does not see as pointers, so if there are only weak pointers to a piece of memory the garbage collector will recycle that piece of memory. As a consequence, a weak pointer cannot always be dereferenced, sometimes the target as been recycled. Dereferencing of a weak pointer it therefore done using a determ predicate.

So in short a weak pointer is a pointer that will not keep memory alive.