Mombu the Programming Forum

Go Back   Mombu the Programming Forum > Programming > Programming languages > Doesnt Scheme support Scoping
User Name
Password
REGISTER NOW! Mark Forums Read




Reply Bookmark and Share
1 23rd October 10:05
icn_ok
External User
 
Posts: 1
Default Doesnt Scheme support Scoping



hello,

I think that all languages support Scoping(Block).
For example, in C/C++,

if (...)
{
}
else
{
}

in Pascal,

begin;
...
end;

So, my question is if Scheme doesn't support scoping like above.
I tried (begin ... ) statement,
but it seems not work.

I've been finding any other scoping command, but I was not able to.

If you know how to scope a group of commands,
please let me know.

thanks in advance.
  Reply With Quote


 


2 23rd October 10:06
joe marshall
External User
 
Posts: 1
Default Doesnt Scheme support Scoping



"ICN_OK" <cobra1030@hanmail.net> writes:

I don't know what you mean by "Scoping(Block)"

Many languages don't support block structure. Many languages don't
support lexical scoping. Many languages support neither.


I imagine (and I'm just guessing) you are looking for the LET form:

(let ((x 22))
... forms that can use x ....)
  Reply With Quote
3 23rd October 10:06
icn_ok
External User
 
Posts: 1
Default Doesnt Scheme support Scoping


Thanks for your reply.
Please understand me, I am not good at English.

In C/C++, I can insert TWO OR MORE statements by grouping with
" { } " (round brackets?)

For example, compare below TWO:

** THE FIRST

if (a == 0)
cout << "TRUE";
else
cout << "FALSE";

** THE SECOND

if (a == 0)
{
cout << "TRUE";
cout << "A is Zero";
}
else
{
cout << "FALSE";
cout << "A is not Zero";
}


by using round brackets { }, I was able to insert more than one
statement.

In Scheme, (I use Dr. Scheme)
I was not able to insert more than one statement after if statement.

In C, I used the round brackets { } instead of semi colon,
I'd like to know how to insert two or more statements in Scheme.

I think you now understood what I mean.
I hope you or anyone answer the question, thank you.
  Reply With Quote
4 23rd October 10:07
abdulaziz ghuloum
External User
 
Posts: 1
Default Doesnt Scheme support Scoping


This is called a sequence and it has nothing to do with scope.
In scheme, use begin:

(if (= a 0)
(begin
(display "TRUE")
(display "A is zero"))
(begin
(display "FALSE")
(display "A is not zero")))

Aziz,,,
  Reply With Quote
5 23rd October 10:07
anton van straaten
External User
 
Posts: 1
Default Doesnt Scheme support Scoping


You are probably using one of the DrScheme student language levels.
These language levels give you a limited language, designed for
students, using the book at htdp.org.

If you are not working from that book, then you must change your
language level in DrScheme. Select "Language" from the DrScheme menu,
then select "Choose Language", and set the language to "Standard
(R5RS)". Or, if you want extra features specific to PLT Scheme, select
"Pretty Big" under "PLT".

Then you can use (begin ... ) to do what you want.

Anton
  Reply With Quote
6 23rd October 10:07
christopher browne
External User
 
Posts: 1
Default Doesnt Scheme support Scoping


TeX doesn't; ditto for many macro-based languages.

Probably ditto for SNOBOL.

Definitely typical macro assembler language do not support Algol-style
blocks.

Scheme is most certainly a block-structured language like Algol.

It is noted as a language that popularized lexical scoping, which is
now quite common...


It's pretty typical to group a block of commands that use some common
bound values in a LET structure.

Thus...

(let ((foo a) (bar b))
(if foo
(do-something-with-it foo)
(do-something-with-it bar)))

Where foo and bar are bound to a/b within the scope of the LET
block...
--
(reverse (concatenate 'string "moc.liamg" "@" "enworbbc"))
http://cbbrowne.com/info/
If we were meant to fly, we wouldn't keep losing our luggage.
  Reply With Quote
7 23rd October 10:08
jens_axel_sgaard
External User
 
Posts: 1
Default Doesnt Scheme support Scoping


In that case he should use (and ...).

--
Jens Axel Søgaard
  Reply With Quote
8 23rd October 10:08
jens_axel_sgaard
External User
 
Posts: 1
Default Doesnt Scheme support Scoping


For those who haven't read the book: Until (begin ...) is
introduced all situation in which sequencing is neccessary
(mostly drawing functions) is carefully planned to be solvable
with (and ...).

--
Jens Axel Søgaard
  Reply With Quote
9 23rd October 10:10
bruce lewis
External User
 
Posts: 1
Default Doesnt Scheme support Scoping


"ICN_OK" <cobra1030@hanmail.net> writes:


This is the kind of redundancy you typically see in languages that use
statements instead of expressions. If you want to understand functional
programming you need to stop thinking of "if" as a control-of-flow
statement and start thinking of it as an expression that chooses between
two other expressions.

(display (if (zero? a) "TRUE" "FALSE"))
(newline)
(display (if (zero? a)
"A is Zero"
"A is not Zero"))
(newline)
  Reply With Quote
10 23rd October 10:15
jack unrue
External User
 
Posts: 1
Default Doesnt Scheme support Scoping


cout << (a == 0 ? "TRUE A is Zero" : "FALSE A is not Zero");

--
Jack
  Reply With Quote
Reply


Thread Tools
Display Modes


Some other forums that might be of your interest : Development, Ada, Apple script, Assembler, Awk, Beos, Basic, C, C++, C#, C# .net, .net, .net frameworks, Asp .net, Clarion, Clipper, Clos, Clu, Cobol, Coldfusion, Delphi, Dylan, Eiffel, Forth, Fortran, Haskell, Hermes, Icon, Idl, Java, Java script, Jscript .net, Jcl, Linoleum, Lisp, Lotus, Limbo, Logo, Ml, Mumps, Oberon, Postscript, Pop, Pl1, Prolog, Python, Ruby, Pascal, Perl, Php, Rebol, Rexx, Sed, Sather, Scheme, Smalltalk, Tcl, Vhdl, Vrml, Visual basic, Visual basic .net, Yorick, Mysql, Omnis, Postgresql, Xbase, Access, Oracle, Adabas, Berkeley, Btrieve, Filemaker, Gupta, Db2, Informix, Ingres, Mssql server, Object, Olap, Paradox, Rdb, Revelation, Sybase, Theory, Dbase, Html, Java script, Css, Flash, Photoshop, Corel script, Xml, Tech, Beos, Gem, Hp48, Hpux, Linux, Mac, Ms-dos, Os2, Palm, Solaris, Ti99, Windows, Xenix, Aos, Chorus, Geos, Inferno, Lantastic, Lynx, Mach, Minix, Netware, Os9, Parix, Plan9, Psos, Qnx, Xinu, Sco, Unix, Aix, Aux, 386bsd, Bsdi, Freebsd, Netbsd, Openbsd, Ultrix, Amd, Intel, Aptiva, Buz, Deals, Homebuilt, Overclocking, Programming, Extra forums


Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666