f



Why can't "define" double as "set!"?

hi

Is there any good reason that "define" shouldn't double as "set!"?

0
dillogimp1 (84)
4/5/2007 8:32:54 AM
comp.lang.scheme 4781 articles. 0 followers. Post Follow

3 Replies
906 Views

Similar Articles

[PageSpeed] 21

dillogimp@gmail.com wrote:
> Is there any good reason that "define" shouldn't double as "set!"?

Yes: DEFINE defines variables, SET! changes the values of (defined)
variables:

(set! x 1) => wrong!
(define x 0)
(set! x 1)
x => 1

Some interpreters may implicitly define variables when you try
to set! them for the first time, thereby making DEFINE and SET!
/appear/ to be the same.

-- 
Nils M Holm <n m h @ t 3 x . o r g> -- http://t3x.org/nmh/
0
4/5/2007 8:47:02 AM
On Thu, 5 Apr 2007 08:47:02 +0000 (UTC), Nils M Holm
<before-2007-07-01@online.de> wrote:

>dillogimp@gmail.com wrote:
>> Is there any good reason that "define" shouldn't double as "set!"?
>
>Yes: DEFINE defines variables, SET! changes the values of (defined)
>variables:
>
>(set! x 1) => wrong!
>(define x 0)
>(set! x 1)
>x => 1
>
>Some interpreters may implicitly define variables when you try
>to set! them for the first time, thereby making DEFINE and SET!
>/appear/ to be the same.

Additionally, implicit defines do not work in compiled code and may
work only at the top level in an interpreter.  

Within a function, setting a variable that hasn't been declared (at
the top level using define, in a lambda list or in a let) will fail if
the function is compiled and may fail if the function is interpreted.

(define x 0)
(define (f z)
  (let ((w 0))
     (set! w 1)
     (set! x 1)
     (set! z 1)
     (set! y 1)))
(f 0) 
set!: cannot set undefined identifier: y


So, it may work in some situations, but don't count on it.

George
--
for email reply remove "/" from address
0
George
4/6/2007 5:43:13 AM
<dillogimp@gmail.com> wrote:
> hi
>
> Is there any good reason that "define" shouldn't double as "set!"?
>

Doesn't define extend the environment function with a new binding whereas
set! modifies the store function?



0
4/8/2007 6:08:38 AM
Reply:

Similar Artilces:

about "++" and "--"
why this program snippet display "8,7,7,8,-7,-8" the program is: main() { int i=8; printf("%d\n%d\n%d\n%d\n%d\n%d\n",++i,--i,i++,i--,-i++,-i--); } > why this program snippet display "8,7,7,8,-7,-8" Ask your compiler-vendor because this result is IMHO implementation-defined. Check this out: http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.15 http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.16 Regards, Irina Marudina fxc123@gmail.com wrote: > why this program snippet display "8,7,7,8,-7,-8&q...

why "::", not "."
Why does the method of modules use a dot, and the constants a double colon? e.g. Math::PI and Math.cos -- Posted via http://www.ruby-forum.com/. On Oct 26, 2010, at 01:48 , Oleg Igor wrote: > Why does the method of modules use a dot, and the constants a double > colon? > e.g. > Math::PI and Math.cos For the same reason why inner-classes/modules use double colon, because = they're constants and that's how you look up via constant namespace. Math::PI and ActiveRecord::Base are the same type of lookup... it is = just that Base is a module and PI is a float....

"out" and "in out"
Hi i found the following explaination: In Ada, "in" parameters are similar to C++ const parameters. They are effectively read-only within the scope of the called subprogram. Ada "in out" parameters have a reliable initial value (that passed in from the calling subprogram) and may be modified within the scope of the called procedure. Ada "out" parameters have no reliable initial value, but are expected to be assigned a value within the called procedure. What does "have no reliable initial value" mean when considering the "out" parameter? By chance I created a small program as follows: =========== s : string := "CAT"; procedure modify ( s1 : out string ) is begin s1(2) := 'U'; end modify; ... put ( modify(s) ); =========== now I get as a result "CUT", and i dont understand why i get this result. Doesnt the "out" specify that its initial value isnt passed in via the parameter? But it seems to be passed in the above. In fact the "out" is acting like an "in out". I am a little confused. Could someone shed some light on this? Many thanks! zork "zork" <zork@nospam.com> wrote in message news:4104d5de@dnews.tpgi.com.au... > Hi i found the following explaination: > > In Ada, "in" parameters are similar to C++ const parameters. They are > effectively read-only within the scope of the called subprogram. > Ada "in out&q...

Urgent need """""""""""INFORMATICA DEVELOPER"""""""""""""
Hello Partners, How are you ? Please find the requirements below. Title: Database/ETL Developer Duration: 6 months Location: NY Exp: 7+ Locals preferred Database/ETL requirements (Mandatory) Candidate must have worked with financial instruments, preferably Mutual Funds but, Equities are also ok. PL/SQL - packages, Stored procs, Functions, Aggregate functions, Pipelined Functions Informatica 8.6 - especially complex mappings, complex maplets, complex workflows, transformations Oracle 10g/11g Unix/Linux shell scripting Database/ETL requirements (Optional) Data warehousing experience Threading and job concepts in 10g/11g Cost based Optimizer concepts in 10g/11g Must : Experience with XML files and partitioning concepts in Oracle, Collections, Material Views Note : No phone calls please. : send Resumes to karthik@bhaninfo.com Thanks & Regards Karthik BhanInfo karthik@bhaninfo.com ...

"In" "Out" and "Trash"
I just bought a new computer and I re-installed Eudora Light on my new computer. But when I open Eudora, the "In", "Out" and "Trash" links are not on the left side of the screen the way they were on my old computer. How can I get these links back on the left side of the screen? Thank you. On 25 Mar 2007 09:49:22 -0700, "abx" <abfunex@yahoo.com> wrote: >I just bought a new computer and I re-installed Eudora Light on my new >computer. But when I open Eudora, the "In", "Out" and "Trash" links >are ...

Instruction at "0x00FC3D70" use memory address "0x00000000". Can't be "read".
Yesterday, ALL code in python work and nothing when I close(finish) a code. Today, when I close, some raise this windows error : Instruction at "0x00FC3D70" use memory address "0x00000000". Can't be "read". Click on "OK" to exit program. Why this error, today and not before today? Askari Askari wrote: > Yesterday, ALL code in python work and nothing when I close(finish) a code. > Today, when I close, some raise this windows error : > > Instruction at "0x00FC3D70" use memory address "0x00000000". Can't be &...

Urgent JAVA Requirement in """"""NEW YORK"""""""""
Hello Partners, How are you ? Please find the requirement below. Location : NY Duration : 8 mnths Rate :Open Job description: Java/J2EE Web Service Developer =B7 (4+ years of application development experience in Java/J2EE and Web service technologies. =B7 Experience with spring & Hibernate. =B7 Experience with J2EE Application Server (preferably Web logic). =B7 Preferable Aqua logic DSP Experience =B7 Preferable Sonic ESB Composite Service experience Experience working in UNIX environment. Good working knowledge of Oracle RDBMS and PL/SQL) Note : Please send your updated resume along with contact no to Karthik@bhaninfo.com. Thanks & Regards Karthik BhanInfo karthik@bhaninfo.com # 1572, 7 th Floor Suites, 1 Blue Hill Plaza Pearl River,NY-10965 www.bhaninfo.com ...

Question about "sprintf" "@" "do for"
Hello, this works: A1=3D1 A2=3D2 A3=3D3 i=3D1 vari=3Dsprintf("A%.f",i) print vari,"=3D",@vari i=3Di+1 vari=3Dsprintf("A%.f",i) print vari,"=3D",@vari i=3Di+1 vari=3Dsprintf("A%.f",i) print vari,"=3D",@vari do for [i=3D1:3]{ vari=3Dsprintf("A%.f",i) print vari } But I want to have "print vari,"=3D",@vari" in the loop. But it dosen't=20 work. Why can't I use "print vari,"=3D",@vari" in the loop? Is there a=20 solution for? J=C3=B6rg Jörg ...

puts "\\".gsub("\\", "\\\\")
Hello, I have a mini-ruby quiz. Guess what this line of code writes to the console, then try it for yourself: puts "\\".gsub("\\", "\\\\") Why is that so? Martin From: martinus [mailto:martin.ankerl@gmail.com]=20 # Hello, I have a mini-ruby quiz. Guess what this line of code writes to # the console, then try it for yourself: # puts "\\".gsub("\\", "\\\\") puts "\\".gsub("\\", "\\\\") \ #=3D> nil # Why is that so? faq. escaping the escape in sub/gsub. search the archives. maybe you want somethin...

Gary Sokolich """"""
"""""""""" http://www.manta.com/c/mmlq5dm/w-gary-sokolich W Gary Sokolich 801 Kings Road Newport Beach, CA 92663-5715 (949) 650-5379 http://www.tbpe.state.tx.us/da/da022808.htm TEXAS BOARD OF PROFESSIONAL ENGINEERS February 28, 2008 Board Meeting Disciplinary Actions W. Gary Sokolich , Newport Beach, California �V File B-29812 - It was alleged that Dr. Sokolich unlawfully offered or attempted to practice engineering in Texas (...) Dr. Sokolich chose to end the proceedings by signing a Consent Order that was accepted by ...

Help! Can't read file with the char's. " / " and "." !
&nbsp; Hi fellows! &nbsp; I got this file : example.&nbsp;&nbsp; &nbsp; 13-06-06 12:30:20,526&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-3,568&nbsp; 13-06-06 12:30:20,529&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-13,528 13-06-06 12:30:20,556&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-30,568 .. .. ..&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; My program writes this file, and in my program i also got a&nbsp; ReadFile.VI, to read this file and plot the data and i had no problem with that. Then I tried in another computer&nbsp; (with&nbsp;american english characters) . then when &nbsp;my program writes a&nbsp;file there I got the file look like this: &nbsp; 13/06/06 12:30:20.526&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-3.568&nbsp; 13/06/06 12:30:20.529&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-13.528 13/06/06 12:30:20.556&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-30.568 .. .. You can see that the caharacters "- " and&nbsp;", " are replaced with "/ " and&nbsp;". " Then when want to read&nbsp;this file with in my ReadFile.VI, the scan string&nbsp;comes with an error. So I managed this problem with&nbsp;replacing the american char's&nbsp;with the eurpaen char's....

"define" and "malloc" more
Hi all, In fact, I want to let my memory run out. And see what will happen. My system is windowsXp. Memory is 256M.I think my cdes will apply more memory than I have. Codes are below: #include <stdlib.h> #include<stdio.h> #define MAX 1000000000 int main(void) { long double *temp = (long double*)malloc (MAX * sizeof(long double)); long double *temp1 = (long double*)malloc (MAX * sizeof(long double)); putchar(77); getchar(); getchar(); return 0; } But run these codes in my IDE, I do not say anything wrong in my system. So could anyone help? ever...

"refreshdata" against "set"
Which one is better, "refreshdata" or "set"? Simply by looking at the code I've noticed that refreshdata does: 1) Finds all the properties of the object which end with 'DataSource' 2)Evaluates all of the relevant variables in the upper workspace 3) Does set(h,....) It looks like there is no advantage in using refreshdata, as it ultimately calls set, but does bunch of other operations. In my GUI, I've implemented polygon movement with both, and using directly "Set" is much smoother. Please correct me if I'm wrong. ...

Setting "From:" in "vacation"
The "vacation" program (both the old binary and the newer perl) creates messages from the user saying he'll read his mail when he gets back. Trouble is, they seem to come from user@localhost.localnet instead of user@company.com, so the recipient might not recognise them and even bin them as spam. He certainly can't reply to them. I can't see a setting in vacation for this - is there a way for sendmail settings to fix this? TIA Mike Yates <trawled@fonehelp.co.uk> wrote in message news:1122920121.908517.16970@g44g2000cwa.googlegroups.com > The "vacation" program (both the old binary and the newer perl) > creates messages from the user saying he'll read his mail when he > gets back. Trouble is, they seem to come from user@localhost.localnet > instead of user@company.com, so the recipient might not recognise > them and even bin them as spam. He certainly can't reply to them. > I can't see a setting in vacation for this - is there a way for > sendmail settings to fix this? http://www.sendmail.org/faq/section3.html#3.1 Meanwhile I've fixed it, but the FAQ had little to do with it. I was using Redhat9, whose sendmail does not include vacation, but there's an RPM in "Contrib". That is an old version without -s, -l or -d options so I installed Igor Livshit's latest Perl version. The problem then was that sendmail was using the old version from /usr/bin, despite .forward actually SPECIFY...

Why can't push a "const auto_ptr" into a "vector"
Hi, I want to push a const auto_ptr into a vector, but the compile reports errors. Below is the code. class Folder; class Result; class Results { public: int size(){return _Items.size();} const vector<const auto_ptr<Result> >& Items()const{return _Items;} Results(); ~Results(); private: vector<const auto_ptr<Result> > _Items; }; Results::Results() { typedef list<const auto_ptr<Result> > ResultVector; Result* hdresult = new Result(); auto_ptr<Result> hdptr(hdresult); _Items.push_back(hdptr); } The c...

"A" is not equal "A"?
I was trying to convert String Array to String A through cycle and than compare the result with String B but eventhough results were the same it returned false. I'am working in BlueJ 3.1.0 Code is: public boolean Method () { String[] Example = {"a","b","c"}; String A = ""; String B = "abc" for (int i = 0; i<3 ; i++) { A = A + Example[i]; } if (A == B) { return true; } } never got true... I appreciate any suggestions how to solve this Den 08.04.2014 10:06, skrev 245dav@gmail.com:...

"==" is NOT TRUE "==", WHY?
[CODE START] x=5; y=8; if (x + y + 1E-15 == 13) a = 3 else a = 8 end [CODE END] When x + y + 1E-15, the code above returns a = 8. When x + y + 1E-16, the code above returns a = 3. Why? Kindly advise. Thanks. "onemilimeter Chen" <onemm@example.com> wrote in message <g7adrj$5tr$1@fred.mathworks.com>... > [CODE START] > x=5; > y=8; > if (x + y + 1E-15 == 13) > a = 3 > else > a = 8 > end > [CODE END] > > When x + y + 1E-15, the code above returns a = 8. > When x + y + 1E-16, the code above returns a = 3. > > Why? ...

Re: "out" and "in out"
"no reliable initial value" means, you cannot rely on the value, but it may have a value. This depends on the parameter passing mechanism, which is _not_ related to the parameter mode (contrary to what many people think). So the parameter mode is there (nearly) solely for the information of the reader. The parameter passing mechanism for all kinds of parameters is defined in the RM. There are parameters passed by copy (in and out), by reference; for some it is explicitly left undefined. In your case, the passing mechanism is by reference, so you get what you get. But don't rely on this, rely only on the mode, i.e. the parameter st is undefined upon entering the procedure modify, so when you only write component 2, upon return, only component 2 has been written. Under slight variations, the result of your code might be <garbage character>U<garbage character>. Another thing: Don't rely upon s1'First = 1. Component 2 might not exist. You could call modify like so: X: String (25..30); modify (X); Now s1(2) inevitably will raise Constraint_Error. ____________________________________________________ Aufnehmen, abschicken, nah sein - So einfach ist WEB.DE Video-Mail: http://freemail.web.de/?mc=021200 "Christoph Karl Walter Grein" <AdaMagica@web.de> wrote: > > In your case, the passing mechanism is by reference, so you get what you get. But don't rely on this, rely only on the mode, i.e. the parameter st is undefined...

how to change "/" to "\"
iam new to shell scripting and i have plz can anyone help in changing the pattrern "/" to "\" using the sed command. olympie@gmail.com wrote: > iam new to shell scripting and i have plz can anyone help in changing > the pattrern "/" to "\" using the sed command. sed 's/\//\\/g' will replace all '/' with '\' srp -- http://saju.net.in Saju Pillai <saju.pillai@gmail.com> wrote: >> iam new to shell scripting and i have plz can anyone help in changing >> the pattrern "/" to "\" using ...

why have both "." and "->" ?
I used to remember why c++ needed both ? Could somebody help me here ? For example class A{ f(); }; A* aa; You could do either "aa->f()" or "(*aa).f()". So why does C++ need both operators. Raj "raj" <rajkumar@hotmail.com> schreef in bericht news:d7fee6d0.0406230748.694b966b@posting.google.com... > I used to remember why c++ needed both ? > Could somebody help me here ? > > For example > > class A{ > f(); > }; > > A* aa; > > You could do either "aa->f()" or "(*aa).f()". So why does C++ need both operators. > > Raj There is a difference I believe that xxxx->yyyy is used if xxxx is a pointer to an object/class and xxxx.yyyyy if xxxx is the object/classs > class A{ > f(); > }; > > A* aa; > > You could do either "aa->f()" or "(*aa).f()". So why does C++ need both operators. IMHO it's simply convenience. Bye, Marco raj wrote: > > You could do either "aa->f()" or "(*aa).f()". So why does C++ need both > operators. The second form involves more typing and requires more effort to read. -- Russell Hanneken eunaarxra@cbobk.pbz Use ROT13 to decode my email address. In message <WOhCc.15115$Wr.8451@newsread1.news.pas.earthlink.net>, Russell Hanneken <me@privacy.net> writes >raj wrote: >> >> You could do either "aa->f()" or "(*aa...

what does the "+" and the "-" mean?
I recently read what the "+" and the "-" signs mean for compact discs. Of course, a friend has just asked me and I now forget. I've searched all over the place with no results. Anyone know? TIA! .. -------------------------------------- Mike Richter, were you born with "Scam Artist" emblazoned on your face? -------------------------------------- roscoe james wrote: > > I recently read what the "+" and the "-" signs mean for compact discs. Of > course, a friend h...

Can't locate object method "first" via package "attempt" (perhaps you forgot to load "attempt"?) at ....
"Can't locate object method "first" via package "attempt" (perhaps you forgot to load "attempt"?) at E:\Inetpub\....\N_Clt_prf.pl line 38."I get this error on a perl program that prints & processed a form.Program was working until I made a simple (cosmetic) change. Could not find any reference to this error.Could anyone our there help?Thanks. "GMI" <Admin@GoMonitor.com> wrote in news:11bbgp4iovmsdb@corp.supernews.com: > "Can't locate object method "first" via package "attempt" (perhaps you >...

Dijkstra's "Enumeration" = "Metrics" his "Abstraction" = "Quality"
"Enumerative reasoning is only an adequate mental tool under the severe boundary condition that we only use it very moderately. We should appreciate abstraction as our main mental technique to reduce the demands made upon enumerative reasoning." ~ EW Dijkstra This is critically decisive because Dijkstra is saying that in most *software engineering" contexts, most of the time, abstraction is key relative to "metrics", the numerical, the quantitative. It is a TOWWWEEERRRING, grand slam "home run". It is of Doug William's 3-4 perfectly pitched Super Bowl touchdowns. It is growth in insight after Dijkstra one of THE very best ran into major impasses attempting to drive development with metrics. His insight is that ABSTRACTION should "lead" the way. While there is the dialectic: metrics<=>abstraction The predominant factor to engage and lead software engineering by is "abstraction". So notation wise better: metrics<=>abstraction* And to denote analyzing or summarizing the dialectic applied in whatever context, from point 'a' to 'b': a,b{ metrics<=>abstraction* Discrete points: a,b; l,q{ metrics<=>abstraction* Have at your own meaningful fun! Elliott -- Global Plans + IID = part of an optimal approach On Wed, 4 Feb 2004 23:36:17 -0500, "Universe" <universe@tAkEcovadOuT.net> wrote: >"Enumerative reasoning is only an adequate mental tool und...

"Can't call method "disconnect" on an undefined value..."
Hey there anyone, I am new at this and I am trying to figure this out and I don't know too much, but I keep getting this error when trying to run my cgi page can anyone help, please. Here is the error: Can't call method "disconnect" on an undefined value at /home/virtual/site7/fst/var/www/cgi-bin/affiliates/common.sub line 44. Here is the script I am trying to run: #!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); #!/usr/local/bin/perl -w ################## Form Processing Function ######### if ($ENV{'REQUEST_METHOD'} eq 'GET') { # Split the name-value pairs @pairs = split(/&/, $ENV{'QUERY_STRING'}); } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') { # Get the input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @pairs = split(/&/, $buffer); } foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/<([^>]|\n)*>//g; $value =~ s/\<//g; $value =~ s/\>//g; $value =~ s/\|//g; $value =~ s/\*/\\\*/g; $value =~ s/\?/\\\?/g; $value =~ s/\+/\\\+/g; $FORM{$name} = $value; } #require "/var/www/cgi-bin/affiliates/config.cgi"; # you might need the full path to this file require "/home/virtual/site7/fst/var/www/cgi-bin/affiliates/config.cgi"...

Web resources about - Why can't "define" double as "set!"? - comp.lang.scheme

Resources last updated: 3/29/2016 8:20:42 PM