Getting Squeak to write Squeak (a feeble effort at LISPY stuff)

mwgrant2001 mwgrant2001 at yahoo.com
Mon Nov 17 04:25:16 UTC 2003


I want to write code that will create a instance of a class and I 
want to name the instance by converting a string into a symbol, e.g.,

   assume class Node exists, and that I want to create 
   an instance of Node named velocity. (The idea is to 
   input 'velocity' via an interactive dialog (FillInTheBlank), 
   so
   
     'velocity' ----> velocity  (instance of Node)
   
It being logical that such a method probably has 'eval' in it, I was 
able to find 'evaluate:' which looked real nice. So, a little 
experimentation follow. Basically, I found that I am able to evaluate 
an expression but apparently not an assignment. This doesn't surprise 
me and even seems vaguely familiar. But I am stuck for the moment.

To wit, using TextMorph in lieu of Node:
          
==========A little arithmetic======================      
"Separate 'print It' for each line: "
  ans _ FillInTheBlank request:'Code?'. '4/3.1'
  Compiler evaluate: ans.  1.290322580645161
  4/3.1 1.290322580645161  #check

  
"Select all and  'print It' : "
  ans _ FillInTheBlank request:'Code?'. 
  Compiler evaluate: ans.  1.290322580645161

===========Now try assignment of new instance,
   (Again, TextMorph used in lieu of Node)  
"Separate 'print It' or 'do it' for each line: "
  b _ TextMorph new.
  b  openInWorld.
  b contents. a Text for 'abc'
  b contents: 'I am King of TextMorphs'.
  b contents.  a Text for 'I am King of TextMorphs'

  
" Select lines 1-4 and 'do it', then 'print It on last two :"
  ans _ FillInTheBlank request:'Code?'.  
  ans _ FillInTheBlank request:'Code for new TextMorph'. 
  ans  'c _ TextMorph new.'
  Compiler evaluate: ans.
  ans  'c _ TextMorph new.'
  c nil

* Note _ is of course :=

  
Any suggestions? (Still on lower part of learning curve). FYI as an 
excercise I working toward a simple app. to create an influence 
diagrams and subsequently evaluate decision trees. 

I also hope to try an MVC version (portability? to VW and Dolphin).
Hence I will be poking about for documentation on graphics in MVC. 
Any recommended starting points?

Regards,

Michael Grant




More information about the Squeak-dev mailing list