Monthly Archives: December 2022

CodeParadise on Pharo11

Hi all. A small holiday present for anyone interested: https://github.com/ErikOnBike/CodeParadise now runs on P10 (and P11 with some care)! If you are using it on P8, please unload the CP-ClientEnvironment and reload it using the “pharo8” branch: 

Metacello new
  repository: 'github://ErikOnBike/CP-ClientEnvironment:pharo8';
  baseline: 'CodeParadise';
  load.

P11 seems to have some issues sometimes with restarting the image. Have not found the exact cause. Will look into this.

Happy holidays!

Bloc Update

Hello, this is my new update after two weeks.

Taking advantage of the VM release

The recent Pharo VM Release v9.0.21 for Windows, Mac and Linux was great for our Bloc project since we had some troubles with the graphic libraries dependencies. We take advantage in two aspects:

Simpler install instructions. Getting the project installed is now a simple script, as any other. Before, we had additional steps according to the OS platform (on Mac, via brew or macport; on Windows, by downloading dlls in a zip).

CI running again. The GitHub workflows have been broken some time. The reason was the difficulty to get the VM and update it with updated graphic libraries in the script. Happily, with the new VM release we have restored jobs in all three platforms. After fixing CI, some hidden bugs did pop up, such as an error when scanning fonts on Windows (fixed). Still not everything green, but it’s already good that CI is back!

Outskirts inside and outside

Some geometries now provide an explicit Cairo path to draw the border inside or outside, for two main reasons:

Rendering speed. A recent Bloc Update showed that rendering elements with border inside or outside was significantly slower than centered borders. Now, they are almost as fast as centered outskirts.

Dashed borders. There was a visual issue on elements with dashed border when the outskirts is not centered, i.e. inside or outside. Now it works:

Centered, inside and outside outskirts border

Closed issues on dashed borders:

For the moment, this improvement applies only for circle, rectangle and rounded rectangle, but will be extended to more geometries.

Gaussian shadow effect

In a nutshell, a general approach to create the shadow of a visual element is:
– take the alpha-channel of the element (an 8-bit image)
– apply an approximation of Gaussian blur on it
– paint the shadow color (with an offset), using as a mask the intermediate 8-bit image
– finally, paint the element on top of the shadow.
For example, SVG specifies the drop shadow filter like that. The big question was how to do Gaussian blur step, as Cairo doesn’t provide it out-of-the-box. The current solution is the adaptation of a linear algorithm (on the number of pixels) that looks good:

This element was created with:

BlElement new
	geometry: (BlRoundedRectangleGeometry cornerRadius: 50);
	size: 500@100;
	border: (BlBorder builder
			paint: Color blue;
			width: 15;
			dashArray: #(20);
			build);
	effect: (BlGaussianShadowEffect
  			color: Color orange
			width: 20
			offset: 20 asPoint);
	yourself

Warning

This implementation iterates over the pixels, all in CPU, which has its limitations. For example, on large and animated elements. If we implement some hardware accelerated alternative, this could be a solid fallback. However, in an element animation where only offset or color change, then caching the 8-bit image with the shadow mask should work very well.

Rendering regression tests

The following image gallery illustrates examples added to test regressions in rendering:

Binding for SVG and PDF Cairo surfaces

Our Cairo bindings in Alexandrie now support drawing to SVG and PDF files. Part of this code and tests are based on Athens implementation pushed to Pharo a couple of years ago.

A text with shadows exported to PDF using our Cairo bindings. Text is exported in vector-style, but shadow is a bitmap-style generated by our implementation previously mentioned.

Note: I exported this example using the Cairo bindings directly, without integration with Bloc. But it will be straightforward to integrate it.


Thanks for reading. Questions or feedback? Please refer to the #bloc channel at Pharo Discord server, or the lse-openbloc mailing list. Martín Dias

Tagged , ,

[Ann]  This week (50/2022) on the Pharo Issue Tracker[Ann]

This week, we merged 19 PRs, we closed 36 issues on the main issue tracker.

Features

========

– Fix 12044 introduces hexString and related tests #12045

https://github.com/pharo-project/pharo/pull/12045

Blocks

======

– Enable Constant Block Compilation by default #11931

https://github.com/pharo-project/pharo/pull/11931

– 11984-CompiledBlockhasMethodReturn-is-not-a-good-name #12020

https://github.com/pharo-project/pharo/pull/12020

– 11965-Implement-ContextactiveHome-without-using-home #12063

https://github.com/pharo-project/pharo/pull/12063

– 12014-HECompiledBlockvalue-send-non-exiting-selector-encoderClassName #12070

https://github.com/pharo-project/pharo/pull/12070

– 12034-Context-we-have-both-home-and-methodReturnContext #12098

https://github.com/pharo-project/pharo/pull/12098

– Context: unify #selector and #methodSelector #12100

https://github.com/pharo-project/pharo/pull/12100

Fixes

=====

– 12066-CI-test-failing-on-CI-SystemDependenciesTesttestExternalBasicToolsDependencies #12073

https://github.com/pharo-project/pharo/pull/12073

– Add missing keyDown: message in FTSearchFunction #12087

https://github.com/pharo-project/pharo/pull/12087

– Fix: #12089 the metaclass was placing one # while it should not! + ad… #12090

https://github.com/pharo-project/pharo/pull/12090

– Fix class editor not refreshing when switching between class/instance sides #12095

https://github.com/pharo-project/pharo/pull/12095

– 12110-ReAbstractCritique-asModalWindow #12111

https://github.com/pharo-project/pharo/pull/12111

– Debugger-Implementors-Of #1337

https://github.com/pharo-spec/Spec/pull/1337

– Fix Filetree to Tonel transformation #1646

https://github.com/pharo-vcs/iceberg/pull/1646

– Introduce input validation as first precondition of a refactoring #12050

https://github.com/pharo-project/pharo/pull/12050

Cleanups

========

– merge ReAssignmentWithoutEffectRule and ReRemoveAssignmentWithoutEffectRule #12071

https://github.com/pharo-project/pharo/pull/12071

– Factorize the list of VM parameters #12072

https://github.com/pharo-project/pharo/pull/12072

– Cleanup: lint cleanup regarding class side #initialize categorization for Metacello classes #12076

https://github.com/pharo-project/pharo/pull/12076

– Small lint issue in Athens cairo tests #12092

https://github.com/pharo-project/pharo/pull/12092

– Cleanup: Fix typo in DailyNonInteractiveTranscript>>#initializeStream #12094

https://github.com/pharo-project/pharo/pull/12094

Pharo by Example 9 translated in ukrainian

Hello

We would like to thank Dr. S. Jaroshko for his great translation of Pharo by Example 9 in Ukrainian.

You can find the PDF of this book at https://github.com/mr-Serg/PharoByExample-Ukrainian

Thanks a lot! We are all with you.

S.

Pharo VM Release v9.0.21

Hello, 

  I have released a new version of the Pharo VM for Pharo 9, Pharo 10 and Pharo 11. This VM is accessible right now from Zero-Conf, updating it in the Pharo Launcher or using the usual downloads (as described in pharo.org/download). 

This version includes a series of bug fixes and upgrades on the third-party libraries.

Changelog: 

– Implementing High resolution clock for ARM64 (Used during profiling)
– Updating third party libraries for all the graphic layer.

– Fixing a performance regression on the allocation of opcodes and fix-ups.
        Cleaning only the ones that are going to be used.
        Like this, this version has the same speed than before when allocating in the stack.
– Correctly handling the encoding of the command line arguments of the VM (Windows)
– Allocating the opcodes and fixup structs only once and reusing them (Reducing risk of C Stack Overflow)

Thanks a lot, and any doubt please let me know.

Cheers, 

Pablo on behalf of the whole Pharo team.– 

Pablo Tesone.
tesonep@gmail.com

[Pharodev] This week (49/2022) on the Pharo Issue Tracker

This week we merged 20 PRs. 

Blocks
======
Status: All tests green when compiling with ConstantBlockClosure (but the option is not yet enabled by default)
Work continues to reducing the use of #home, this week by using #homeMethod instead of “home method”

– 12008-Blocks-check-senders-of-compiledCode-can-we-use-homeMethod #12032
https://github.com/pharo-project/pharo/pull/12032

– Context-use-homeMethod #12007
https://github.com/pharo-project/pharo/pull/12007

– some trivial improvements batched (Compiler / Context / Blocks) #12035
https://github.com/pharo-project/pharo/pull/12035

– ConstantBlocks-fix-testIsNotTerminatedWhenItIsInsideLastTerminationMethod #12026
https://github.com/pharo-project/pharo/pull/12026

– ConstantBlocks-Fix-Announcement-Tests #12027
https://github.com/pharo-project/pharo/pull/12027

– Disablequickreturn in blocks #12053
https://github.com/pharo-project/pharo/pull/12053

Refactoring Engine
==================

– Refactor make class abstract #12060
https://github.com/pharo-project/pharo/pull/12060


Features
=====

– Environment: comment #allMethods, add #methods #12028
https://github.com/pharo-project/pharo/pull/12028

– help method for converting integers into corresp… #11800
https://github.com/pharo-project/pharo/pull/11800

– Extend DiffMorph to make it navigable accross differences #11641
https://github.com/pharo-project/pharo/pull/11641

Fixes
=====

– 12049-CI-failure-in-build-testSetUpMethodInSUnitTestsNeedsToBeInRunningProtocol #12051
https://github.com/pharo-project/pharo/pull/12051

– Fix #11995: Handle attempted creation of existing package gracefully #12048
https://github.com/pharo-project/pharo/pull/12048

– Should fix issue 11915 – Pharo compound shortcuts #11954
https://github.com/pharo-project/pharo/pull/11954

– [fix] Pharo issue # 11390: Browsing implementors/senders from source code editors doesn’t browse expected selector #1298
https://github.com/pharo-spec/Spec/pull/1298

– Using version v3.0.4 of libgit to fix the 1.4.4 version in linux #1643
https://github.com/pharo-vcs/iceberg/pull/1643

– Fix Crash when invalid credentials #1642
https://github.com/pharo-vcs/iceberg/pull/1642

Cleanup
=======

– Replacing baseColor method call from class to instance side #12030
https://github.com/pharo-project/pharo/pull/12030

– Fix lint issues #11978
https://github.com/pharo-project/pharo/pull/11978

– 12046 has non standard palette is always returning false #12047
https://github.com/pharo-project/pharo/pull/12047

Pharo10
=======

– [backport] CompiledCode: add #bytecodes #12031
https://github.com/pharo-project/pharo/pull/12031

A Small experiment with Syntax Errors

This is a small experiment about syntax errors when evaluating code. With #evaluate:, we can compile and run a DoIt, for example:

Smalltalk compiler evaluate: ‘1+2’

Imagine you evaluate a String, but it is actually not syntactically correct:

Smalltalk compiler evaluate: ‘1+’

We get an exception (while parsing), a SyntaxErrorDebugger is opened:

This tool is not used often and is fairly odd, in practice we use it for two things: Look at the error message and use the (not easy to find) menu “debug calling process” to see where the eval was called to understand what went wrong (why we consructed a string of invalid code). The problem is that the tool is not easy to understand, and it is not easy to maintain as part of the debugger framework (it is a bit broken even now, especially wrt to editing and continue, which does not matter for DoIts, though).

Could we no do better?

Evaluating code means:

– We parse the string to an AST
– we translate the AST to a DoIt Method
– we execute that method

The error happens inside the parse phase: no method gets contructed, intead an exception is raised. There is quite some machinary to allow re-starting parsing after the error is fixed
(see the exception ReparseAfterSourceEditing and how it is used, quite hard to understand).

The idea that syntax errors are hard errors is quite natural. With batch compilers, there is some effort done to do some auto-repair. This was very useful in old times (punch cards!) to avoid seeing an aborted job the next morning just due to a missing comma. These days it is used to allow better error messages. But it is common to treat syntax errors as hard errors. This is seen as good as they are detected very early and the fact that compiling is not possible is seen as the goal for any kind of error. In the end, type systems try to extend this to non-syntactic problems: If a program is wrong, it should not run. If we call a method that does not exist, the program should not compile.

What if we not follow this standard advice and go the exact opposite direction?

Let’s try:

Our tools parse code after *every* keystroke. The resulting AST is used for syntax highlighting. Which means, we can parse the expression 

‘1+’

without any problem, if we use the same mode for the Parser:

Smalltalk compiler
options: #(+ optionParseErrors);
parse: ‘1+’

We see that the parser created an AST, with a ParseErrorNode as the argument of the message send +. 

This AST would used by the Syntax HighLighter, and for code completion. But it is in the end just the normal AST that the Compiler uses to compile source text to CompiledMethods.

So can we not just implement the code in the compiler to compile this AST?

The node implements the visitor pattern #acceptVisitor:, which calls visitParseErrorNode:. So we can add support to the compiler by just implementing OCASTTranslator>>#visitParseErrorNode:

visitParseErrorNode: anErrorNode 
methodBuilder 
pushLiteralVariable: RuntimeSyntaxError binding;
pushLiteral: anErrorNode;
send: #signalSyntaxError:

This just reads the global Variable RuntimeSyntaxError (which is subclass of Error), pushes the error node itself as an argument and sends #signalSyntaxError:

signalSyntaxError: aNode
“we use signalSyntaxError: instead of signal: so we can quickly check 
compiledMethods for syntax errors by checking the literals”
^(self new errorNode: aNode) signal

To see what the compiler compiled for that expression, lets compile a DoIt method (this is what #evaluate: does to get a method to execute):

compiledMethod := Smalltalk compiler
noPattern: true;
options: #(+ optionParseErrors);
compile: ‘1+’

So it did compile this bytecode, as expected:

49 <51> pushConstant: 1
50 <10> pushLit: RuntimeSyntaxError
51 <21> pushConstant: RBParseErrorNode()
52 <92> send: signalSyntaxError:
53 <60> send: +
54 <5C> returnTop

To finish what #evaluate does, we can evaluate the compiledMethod (with a nil receiver):

compiledMethod valueWithReceiver: nil arguments: #()

and it works! The standard debugger opens, on the RunTimeSyntaxError:

Can we do that by default for #evaluate? Go to OpalCompiler>>#evaluate and add the optionParseErrors line before compiling:


options: #(+ optionParseErrors);
doItMethod := self compile.

If you now run

Smalltalk compiler evaluate: ‘1+’

It will open the normal debugger.

What needs to be improved? 

– The error message is not shown other than in the debugger window title.
(but all the infos to print a nice error in place is contained in the AST)
– Maybe allowing to edit and proceed could be interesting (not that much for evaluate)

(I will turn this into a blog post later)

Marcus

Bloc update

Hello, this is another report on my activity on the Bloc project.

Shadow Effect

Circle sectors with green shadows

This visual effect is quite common in graphical user interfaces, often to highlight certain elements or as a aesthetic decoration. When an element drops a shadow, it usually presents a darken and blurred-edges copy underneath. More in general, a shadow can have a x,y offset, an arbitrary color, and a Gaussian “radius” which can be zero meaning sharp edges.

We received requests to support shadows on the Alexandrie canvas and we have now a basic implementation, for the moment without blur. The first clear challenge was being fast on drawing the effect, however there were other challenges that I will comment briefly.

Open geometries and text

Straight lines, arcs and beziers can have a shadow, that on our first approach was working like on the right. This was following the Sparta-Cairo canvas implementation. But it didn’t look well so we changed it to be more like the SVG’s drop shadow effect (on the left side of the picture).

On text elements, we implemented it like on the picture. This also differs from how the other canvas behaves, casting a rectangular shadow.

Bordered elements with translucent or transparent background

The shadow of a completely opaque element, as on the left of this figure, looks fine as a uniform copy of it. When it is transparent as on the right, it’s clear that the shadow should take into account a border. However, the translucent background may be subject to discussion. We currently draw it as in the SVG specification, which is taking the alpha channel of the element that drops the shadow and uses it as a mask to paint the shadow color.

Border outskirts

Our Alexandrie canvas, on the left.

The border of a Bloc element may be drawn inside, center or outside of the geometry bounds. This parameter, named outskirt, required our consideration as the shadow should match the geometry extent with the appropriate border width and outskirt type.

The figure has a vertical line that separates two ways of drawing the shadow of elements. All hexagons have the same extent, only outskirts differ by column: The left column has outskirt inside, the center one has center outskirt, and the right column has outside outskirt.

Tests and benchmarks, and future work

All screen captures of this report are the output of new rendering tests. They cover a good number of combinations. Pixelated pictures ease comparation, and that’s why you may notice this characteristic on them.

There is a new benchmark for shadows, which shows performance issues that we are working on. Blurred shadow is work in progress.


Thanks for reading. Questions or feedback? Please refer to the #bloc channel at Pharo Discord server, or the openbloc mailing list.

Martín Dias

Tagged , ,

[Pharo-dev] This week (48/2022) on the Pharo Issue Tracker.

This week we merged 34 PRs. 

Features

========

– New refactoring changes preview presenter #11887

https://github.com/pharo-project/pharo/pull/11887

– Creating a method to print the “full” debug stack #11983

https://github.com/pharo-project/pharo/pull/11983

– 11544 enhance socket to show meaningful errors #11921

https://github.com/pharo-project/pharo/pull/11921

– Adding debugger extension visitor to display variables from extensions (as Chest) #402

https://github.com/pharo-spec/NewTools/pull/402

– add a Method Source View for Context #440

https://github.com/pharo-spec/NewTools/pull/440

Blocks

======

– Tests for clean and constant blocks #12015

https://github.com/pharo-project/pharo/pull/12015

– Support #isReturnSpecial on CompiledBlock #11987

https://github.com/pharo-project/pharo/pull/11987

– 11966-Implement-BlockClosurehomeMethod-without-using-home #12000

https://github.com/pharo-project/pharo/pull/12000

– StDebugger-stackSelectionMethodContext-homeMethod #445

https://github.com/pharo-spec/NewTools/pull/445

– use Context>>#homeMethod #12023

https://github.com/pharo-project/pharo/pull/12023

– 11967-Implement-findMethodContextSuchThat #12013

https://github.com/pharo-project/pharo/pull/12013

– ConstantBlock-fix-DebuggerTest #12024

https://github.com/pharo-project/pharo/pull/12024

Fixes

=====

– 11844-Renaming-a-package-loses-all-the-package-extensions #11982

https://github.com/pharo-project/pharo/pull/11982

– [Compiler] fix code generation when compiling syntax errors: EnglobingError #11947

https://github.com/pharo-project/pharo/pull/11947

– fix var lookup in debugger when block pushed on stack #11989

https://github.com/pharo-project/pharo/pull/11989

– Fix print on recursive array #11916

https://github.com/pharo-project/pharo/pull/11916

– 11937-Cycling-of-Halos-does-not-work-anymore #12016

https://github.com/pharo-project/pharo/pull/12016

– Fixed #11946. Added SequenceableCollection>>truncatedToSize and a trait to test it #11988

https://github.com/pharo-project/pharo/pull/11988

– Fix: “Copy stack to clipboard” doesnt copy the whole stack #442

https://github.com/pharo-spec/NewTools/pull/442

Speed

=====

– Fix slow execution time when using CharacterSet or CharacterSetComple… #11991

https://github.com/pharo-project/pharo/pull/11991

– 12006-Performance-Regression-in-Fuel-Serialization-of-Blocks–CompiledMethods #12022

https://github.com/pharo-project/pharo/pull/12022

External Packages

=================

– Updating version of tonel #12003

https://github.com/pharo-project/pharo/pull/12003

– Integrate Roassal3 v0.9.9k #12012

https://github.com/pharo-project/pharo/pull/12012

Cleanup Help

============

– Fix #11949 less help class #11950

https://github.com/pharo-project/pharo/pull/11950

– Fix spechelp problem #11999

https://github.com/pharo-project/pharo/pull/11999

– Fix 11994 Another pass to remove help classes. Waiting for the integr… #11996

https://github.com/pharo-project/pharo/pull/11996

– Removing help support #12001

https://github.com/pharo-project/pharo/pull/12001

– Removing remaing Help Topic references #444

https://github.com/pharo-spec/NewTools/pull/444

– remove help processor #443

https://github.com/pharo-spec/NewTools/pull/443

– remove Spec2-Help #1333

https://github.com/pharo-spec/Spec/pull/1333

Trival Cleanups

===============

– Cleanup STON classes who show lint issue on categorization of #initia… #11964

https://github.com/pharo-project/pharo/pull/11964

– add tag “system” #11985

https://github.com/pharo-project/pharo/pull/11985

– 12009-ProperMethodCategorizationTesttestNoUncategorizedMethods-fails-on-CI #12010

https://github.com/pharo-project/pharo/pull/12010

– Trivial-clean-Morph #12025

https://github.com/pharo-project/pharo/pull/12025